09 January 2017  •  Releases  •  Yali Sassoon

Snowplow Javascript Tracker 2.7.0 released

We are delighted to kick off 2017 with a new release of our Javascript Tracker. Version 2.7.0 includes a number of new and improved features including:

  1. Improved tracking for single-page webapps
  2. Content Security Policy compliance
  3. Automatic and manual error tracking
  4. New configuration options for first party cookies
  5. More elegant Optimizely integration
  6. New trackSelfDescribingEvent method

1. Improved tracking for single-page webapps

The webPage context is invaluable when you analyse or model web data, and want to be able to unambiguously identify which page view to associate with an in-page event. Without this, it is actually impossible to do so if e.g. a user has a web page open on multiple tabs simultaneously.

Historically, the web page context has not worked well at all for single page web apps that track “virtual page views”. Typically in these types of situations, a trackPageView method call is made every time a virtual page view occurs. Older versions of the tracker would not reset the page view ID when a the trackPageView method was called: instead it was only reset when the tracker was reinitialized. That was acceptable on multi-page web apps, when the tracker is reinitialized with each page load, but not on single page webapps using virtual page views, where the tracker is not reinitialized. As a result, typically all the events recorded in a single page app, open on a single tab, would have the same page view ID, however many virtual page views occurred within the app.

With version 2.7.0 of the tracker, that ID is now reset every time the trackPageView method occurs, making it just as easy to understant what page view to associate specific events with on single page webapps as on multi-page webapps.

2 Content Security Policy compliance

Content Security Policy (CSP) is a computer security standard introduced to prevent cross-site scripting (XSS), clickjacking and other code injection attacks resulting from execution of malicious content in the trusted web page context.

With this release the Snowplow Javascript Tracker is now CSP compliant!

3. Automatic and manual error tracking

The JS tracker now supports automatic error tracking! This should make it much simpler to identify unexpected JS errors, and understand the context that those errors occur in (using all rest of the Snowplow data), allowing for faster diagnosis of the underlying issues causing those errors.

To enable automatic error tracking, simply run the following when initializing the tracker:


and make sure that you have created the application error table in Redshift to house the relevant data generated.

In addition you can manually catch errors and track them using the new trackError method.

It is now possible to set the lifetime of device/user cookies, or to disable them altogether, on tracker initialization.

Previously these cookies were always set to last for 2 years. Now you can configure them as documented here.

5. More elegant Optimizely integration

In the previous tracker release we announced Optimizely integration. This made it is straightforward to automatically grab components of the Optimizely Data Object as context with any event that was recorded by the JS tracker.

This release includes a new Optimizely Summary Context which:

  1. Picks out just a subset of fields from the Optimizely Data Object necessary to unambiguously identify what experiment(s) are currently being run, reducing the context footprint
  2. Structures the data in a way that makes subsequent analysis much easier

For both the above reasons we recommend all Snowplow-Optimizely users employ the new summary context rather than the previous contexts.

Huge thank you to Snowflake Analytics’ Narbeh Yousefian for suggesting and designing the updated approach.

6. New trackSelfDescribingEvent method

We’ve added a new trackSelfDescribingEvent method for tracking events where you’ve defined your own event schema e.g.

window.snowplow_name_here('trackSelfDescribingEvent', {
    schema: 'iglu:com.my_company/save_game/jsonschema/2-0-0',
    data: {
        gameId: '123',
        currentPosition: 15,
        currentScore: 12,
        exitOnCompletion: false,
        playerId: 'abc'

The new method is functionally equivalent to the old (and still valid) trackUnstructEvent method. However, the updated name is more accurate: trackUnstructEvent suggests that an unstructured event is being tracked, and as the event is schema’d and is sent into Snowplow with a reference to its own schema, it is actually a very structured data set.

7. Installing the updated tracker

The tracker is available to use here:


There are no breaking API changes introduced with this release, so updating the tracker should be straightforward.

Thoughts or questions? Come join us in our Discourse forum!
Yali Sassoon
Yali is co-founder and analytics lead at Snowplow. You can find in him on , Twitter and LinkedIn.