These docs are for v1.0. Click to read the latest docs for v3.0.

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:

  1. 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.

  1. Instead of (1), you can could also build a utility method that calls both window.analytics and LogRocket.track
function analyticsTrack(...args) {
   window.analytics.track(...args);
   LogRocket.track(...args);
}