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:
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:
- 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);
}
If you have deployed LogRocket by setting it as a Segment Destination, you can also send your Segment events to LogRocket automatically by configuring a Mapping in Segment. This approach requires LogRocket to be deployed via Segment; the code-based approaches above can be used by customers who use Segment alongside LogRocket but do not want to deploy LogRocket through Segment.
Updated 6 months ago