1. Home
  2. Blog
  3. Releases
Releases

Snowplow JavaScript Tracker 0.14.0 released with new features

Alex writes: this is the first blog post – and code release – by Snowplow “springtern” Fred Blundun. Stay tuned for another blog post soon introducing Fred!

We are pleased to announce the release of the Snowplow JavaScript Tracker version 0.14.0.

In this release we have introduced some new tracking options and compressed our tracker for better load times. We have also updated our build process to use Grunt.

This blog post will cover the following changes:

  1. New feature: gzipping
  2. New feature: set user ID from a cookie
  3. New feature: set user ID from a querystring
  4. New feature: pass a referrer through an iframe
  5. New feature: respecting Do Not Track
  6. New build process
  7. Other structural improvements
  8. Upgrading
  9. Getting help

Our hosted JavaScript JavaScript Tracker is now gzipped for CloudFront delivery using a Grunt plugin. This decreases the file size by about 70%, improving load times and perceived website speed. All modern browsers support gzipping (reference).

This new function allows you to set the visitor’s business user ID to the value of a first-party cookie. Its signature is:

function setUserIdFromCookie(cookieName<span class="p">);

For example, this code:

_snaq.push(['setUserIdFromCookie', '_sp_id.4209'<span class="p">]);

will look for a cookie whose name is “_sp_id.4209”. If one is found, the user ID will be set to the value of that cookie.

We have added support for setting the visitor’s business user ID from a field in the querystring of either the current page’s URL or the referring page’s URL. The signatures for the new functions are:

function setUserIdFromLocation(querystringField<span class="p">); function setUserIdFromReferrer(querystringField<span class="p">);

For example, to set the user’s ID to the value of the “id” field in the local querystring, use:

_snaq.push([['setUserIdFromLocation', 'id']]);

And to set it to the value of the “id” field in the referrer querystring, use:

_snaq.push([['setUserIdFromReferrer', 'id']]);

You can now pass the referrer back to Snowplow from inside an iframe. To do this, set referrer=x in the querystring of the iframe’s URL, where ‘x’ is the required referrer. This also works if you set referer=x (with one ‘r’).

Many thanks to community member Josh Spivey for this idea and some suggested code!

Most browsers offer a Do Not Track feature, allowing users to request not to be tracked by websites. You can now respect that preference with:

function respectDoNotTrack(enable<span class="p">);

Use this function like so:

_snaq.push(['respectDoNotTrack', true<span class="p">]);

If the browser’s Do Not Track feature is enabled, the above code will prevent the Snowplow JavaScript Tracker from either setting first-party cookies or sending events to a collector.

We have replaced our custom snowpak.sh Bash script with a standardised Grunt file. This let us use Grunt plugins to automate the build process, from file concatentation and YUI Compression through to uploading to S3 and CloudFront invalidation.

It should also help us move to a more modular project structure and add a test suite in the next release.

We have also:

  • Moved cookie-related functionality into a new file (#77)
  • Moved requestStringBuilder into a new file (#55)
  • Moved functions to detect browser attributes into a new file (#37)
  • Removed getLegacyCookieName (#50)
  • Removed the legacy Piwik debug code (#65)

The upgraded minified tracker is available here:

http(s)://d1fc8wv8zag5ca.cloudfront.net/0.14.0/sp.js 

If you are currently using the path:

http(s)://d1fc8wv8zag5ca.cloudfront.net/0/sp.js 

then you will get the new version automatically.

Check out the v0.14.0 release page on GitHub for the full list of changes made in this version.

As always, if you run into any issues or don’t understand any of the above changes, please raise an issue or get in touch with us via the usual channels.

More about
the author

Avatar
Snowplow Team
View author

Unlock the value of your behavioral data with customer data infrastructure for AI, advanced analytics, and personalized experiences

Image of the Snowplow app UI