Segment
Integrating LogRocket with Segment
Add a LogRocket session recording URL to every Segment integration
LogRocket.getSessionURL(function (sessionURL) {
analytics.track('LogRocket', {
sessionURL: sessionURL,
});
});
Custom Analytics Events
To send all of your Segment events to LogRocket for search (via LogRocket.track()), you can do EITHER of the following:
- Redefine window.analytics to also send data to LogRocket
if (window.analytics) {
const oldTrack = window.analytics.track.bind(window.analytics);
window.analytics.track = (...args) => {
LogRocket.track(...args);
oldTrack(...args);
};
}
You can do the same for .identify
events as well.
- Instead of (1), you can could also build a utility method that calls both
window.analytics
andLogRocket.track
function analyticsTrack(...args) {
window.analytics.track(...args);
LogRocket.track(...args);
}
Updated almost 5 years ago