- Improved tracking for single-page webapps
- Content Security Policy compliance
- Automatic and manual error tracking
- New configuration options for first party cookies
- More elegant Optimizely integration
1. Improved tracking for single-page webapps
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.
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.
4. New configuration options for first party cookies
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:
- 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
- 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.
6. New trackSelfDescribingEvent method
We’ve added a new
trackSelfDescribingEvent method for tracking events where you’ve defined your own event schema e.g.
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.