Segment

Integrating LogRocket with Segment

Segment Destination Configuration

To configure LogRocket as a destination, navigate to the destination catalogue in Segment. You will need your appID. You can find your appID on https://app.logrocket.com under Settings > Project Setup.

Add LogRocket as a destination, then choose the source(s) which you would like to have start sending data to LogRocket. For the configuration, add your appID to the field:

1582

Additional recording configuration options are currently limited to full network sanitization (yes / no) and full input sanitization (yes / no).

Optional Additional Config

If you'd like to use the LogRocket segment destination but need more advanced data redaction configuration, the window.logRocketSettings property will be set as the second parameter to the LogRocket.init call on your page during load. You can use this property to configure more advanced privacy options as detailed here.

πŸ“˜

Please Note

While LogRocket can be configured as a segment destination, we recommend loading the SDK manually when possible in order to minimize obstruction of the SDK. The configuration options below detail how all Segment events can be sent to LogRocket without configuring it as a destination.

Adding Session URL

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