trackJs Destination
Track JS quick info
If you reference Track JS in the Integrations object, call it “Track JS”.
Track JS accepts device-mode data only from Analytics.js.
Track JS monitors your web applications for JavaScript errors, alerting you with amazing context about how the user, application, and network got into trouble. The analytics.js
trackJs Destination is open-source. You can browse the code on GitHub.
This document was last updated on November 26, 2018. If you notice any gaps, outdated information or simply want to leave some feedback to help us improve our documentation, let us know!
Getting Started
Before you start, make sure Track JS supports the source type and connection mode you’ve chosen to implement. You can learn more about connection modes here.
Web | Mobile | Server | |
---|---|---|---|
📱 Device-mode | ✅ | ⬜️ | ⬜️ |
☁️ Cloud-mode | ⬜️ | ⬜️ | ⬜️ |
- From the Segment web app, click Catalog.
- Search for “Track JS” in the Catalog, select it, and choose which of your sources to connect the destination to.
- Enter your Token as retrieved from your Track JS set up page.
- Your changes appear in the Segment CDN in about 45 minutes, and then Analytics.js starts asynchronously loading Track JS onto your page. This means you should remove Track JS’ snippet from your page.
- The Track JS Destination doesn’t use any Segment API calls (e.g. identify, track, etc) so, once it’s loaded, it will automatically start recording error data.
Non-supported options
We do not currently support Track JS’ onError
and serialize
options because they pose a XSS vulnerability.
To work around this issue, however, you can directly set these options in the window._trackJs
object on your page. These options will be merged with the settings you have configured in the interface once the Track JS script is loaded.
We also do not support version
, or sessionId
. These can either be set prior to initialization as described above, or can be set after the snippet has been loaded with the ready
callback
analytics.ready(function(){
window.trackJs.configure({ sessionId: '123456', version: '1.0' });
});
Note that the userId
parameter is automatically determined.
Settings
Segment lets you change these destination settings from the Segment app without having to touch any code.
Application Key
Optional. The name of the section of your application that this Segment project encompasses. For more info see here
Callback BindStack
Whether TrackJS should record the stacktrace for how a callback came to be bound, allowing the creation of an ‘async stacktrace’ in the TrackJS UI. This gives you more context of how the application arrived at the function that failed. Enabling this has a nontrivial performance penalty, test before enabling in production
Callback Enabled
Whether TrackJS should watch for errors on host-function callbacks, such as addEventListener, and setTimeout. Disabling this greatly decreases the likelihood of recording a stacktrace for an error.
Console Display
Whether calls to console.log and other console functions should be displayed into the browser’s console.
Console Enabled
Whether TrackJS should wrap and watch the console for events. If disabled, window.console is not guaranteed to exist in all browsers.
Console Error
Whether TrackJS should transmit errors on calls to console.error.
Enabled
Whether to enable TrackJS for the page. If false, the TrackJS watchers will not be set up. The window.trackJs API will still be available and function locally, but no errors will be transmitted from the browser
Network Enabled
Whether TrackJS should wrap and watch AJAX calls. If disabled, network events will not appear in your Telemetry Timeline.
Network Error
Whether TrackJS should transmit errors when an AJAX call completes with a ‘failing’ status code, 400 or greater. If you wish to customize the list of status codes you want to capture errors from, set this to true and filter out status codes using the onError callback.
Token
You can find your token under Track JS setup page.
Visitor Enabled
Whether TrackJS should watch visitor interaction events, such as clicks and field input.
Window Enabled
Whether TrackJS should watch window.onerror for global errors
This page was last modified: 20 Oct 2020
Need support?
Questions? Problems? Need more info? Contact us, and we can help!