Segment

Integrating LogRocket with Segment

Add a LogRocket session recording URL to Segment

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);
}

📘

Please Note

LogRocket can act as a Segment Source but can not be configured as a Segment Destination