Quick Start

The easiest way to get started with TrackJS is to visit the install screen and copy and paste the code snippet in to your application. It looks something like this:

<!-- BEGIN TRACKJS -->
<script type="text/javascript">
  window._trackJs = {  // Just ensure the global variable is initialized before the tracker script loads.
    token: 'YOUR_TOKEN_HERE' 
  };
</script>
<script src="https://cdn.trackjs.com/releases/current/tracker.js"></script>
<!-- END TRACKJS -->

Token required

The only piece of mandatory information TrackJS requires is your customer token. This is what allows us to ensure your errors are saved correctly, and that you can view them in the UI. If no token is configured, TrackJS will not capture errors. If an invalid token is configured, you will be unable to see any of the error data collected from your sites.

The first script on the page

TrackJS works best as the first script on your page. To faciliate this, our script is dependency free and quite small. We see a very high percentage of errors occur during page load as other scripts are evaluating and loading, so it’s important for TrackJS to be initialized and monitoring as soon as possible.

What’s with the global _trackJs variable used for configuration?

It might look a little odd to declare a global variable before loading our script. We do things this way because we want to make sure TrackJS begins monitoring immediately upon initialization. TrackJS implicitly initializes itself - that is, it starts monitoring without any explicit code action by you. In order for that to work, the configuration needs to be present before TrackJS is loaded.

We do understand that some information may not be available to the application at page load, so there are plenty of ways to customize TrackJS behavior after page load well. Just keep in mind that the token must be specified in the configuration variable up front.

Tracking an error

Once you have TrackJS installed and configured, it might be a good idea to track an error manually - just to make sure everything is working. The tracker script exposes an API you can use to manually send events to us. If you type the following in to your console after TrackJS has loaded and initialized, you will capture an error.

trackJs.track("This is a test of the emergency broadcast system")

If you navigate to your “Recent Errors” screen you should hopefully see something like this!

Bundling

You may feel free to reference the always-up-to-date CDN version of our tracker script (or a specific version of the file). However, many folks prefer to host the tracker script themselves, as part of a bundle. This is totally supported and awesome. We still recommend that you put TrackJS as the first script in your bundle (to catch all the other errors :)) and make sure to get that configuration variable set up before the bundle loads.

Here are some common workflows and how to integrate TrackJS with them

Integrations

For the most part TrackJS will work with any JS library or framework. However, we have some specific integrations to get the most out of some of them.

Examples

There are quite a few common scenarios that we’ve built example code for.