Snowplow JavaScript Tracker 2.9.0 released with consent tracking


We are pleased to announce a new release of the Snowplow JavaScript Tracker. Version 2.9.0 introduces first class methods for tracking when users grant or withdraw consent for their personal data to be processed for specific purposes, as well as new and improved form tracking and the ability to make new tracker sessions client-side.
Read on below the fold for:
- Tracking users granting, and withdrawing, consent to have their personal data processed for specific purposes
- Form tracking with more control
- Start new sessions client-side
- Updates and bug fixes
- Upgrading
- Documentation and help
1. Tracking users granting, and withdrawing, consent to have their personal data processed for specific purposes
Against the backdrop of the incoming GDPR and ePrivacy regulations, this release adds new events to track when users give their consent to, and withdraw their consent from, having their personal data processed for specific purposes.
We envision that many digital businesses will want to track the consent of their users against relatively fine-grained “bundles” of specific data usecases, which we model in Snowplow as consent documents.
The two new consent tracking methods are:
trackConsentGranted
for the giving of consenttrackConsentWithdrawn
for the removal of consent
Each consent event will be associated to one or more consent documents, attached to the event as contexts.
Here is an example of a user opted into data collection per a specific consent document 1234
:
window.snowplow('trackConsentGranted', '1234', // Consent document id '5', // Consent document version 'consent_document', // Consent document name 'a document granting consent', // Consent document description '2020-11-21T08:00:00.000Z' // Expiry of consent <span class="p">);
2. Form tracking with more control
Form tracking now offers the ability to transform form field data with a callback function, transform()
.
For example, use this to hash the field data before sending it for collection:
var config = { forms: { whitelist: ["tracked"] }, fields: { filter: function (elt) { return elt.id !== "private"<span class="p">; }, transform: function (elt) { return MD5(elt<span class="p">); } } <span class="p">}; window.snowplow('enableFormTracking', config<span class="p">);
Documentation can be found here.
3. Start new sessions client-side
The Snowplow JavaScript Tracker uses a session cookie to determine a session – when the session cookie expires, a new session starts. With this release, a new session can instead be started at any time by calling the newSession
function:
window.snowplow('newSession'<span class="p">);
Documentation is found here.
4. Updates and bug fixes
Other updates and fixes include:
- Add
identifyUser
as an alias forsetUserId
(#621) - Make the
newDocumentTitle
variable local (#580) - Enforce that
geolocation.timestamp
is an integer (#602) - Bump the
semver
dependency to 4.3.2 (#625) - Remove
respectOptOutCookie
from the Tracker function comments (#605)
5. Upgrading
The tracker is available to use here:
http(s)://d1fc8wv8zag5ca.cloudfront.net/2.9.0/sp.js
As always, we encourage you to self-host your own copy of the tracker.
There are no breaking API changes introduced with this release.
6. Documentation and help
Check out the JavaScript Tracker’s documentation:
- The setup guide
- The full API documentation
The v2.9.0 release page on GitHub has the full list of changes made in this version.
Finally, if you run into any issues or have any questions, please raise an issue or get in touch with us via our Discourse forums.