From ca9598c1fb9bc408a26793d419b19f39314efe3f Mon Sep 17 00:00:00 2001 From: Jeremy Jackson Date: Fri, 23 Aug 2019 07:11:26 +0000 Subject: Add logic for respecting browser DNT setting --- app/assets/javascripts/tracking.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/assets') diff --git a/app/assets/javascripts/tracking.js b/app/assets/javascripts/tracking.js index 2d0b099cf0b..a852f937eec 100644 --- a/app/assets/javascripts/tracking.js +++ b/app/assets/javascripts/tracking.js @@ -15,8 +15,14 @@ const extractData = (el, opts = {}) => { }; export default class Tracking { + static trackable() { + return !['1', 'yes'].includes( + window.doNotTrack || navigator.doNotTrack || navigator.msDoNotTrack, + ); + } + static enabled() { - return typeof window.snowplow === 'function'; + return typeof window.snowplow === 'function' && this.trackable(); } static event(category = document.body.dataset.page, event = 'generic', data = {}) { -- cgit v1.2.1