Correct syntax/usage for respectDoNotTrack


#1

hi there! Hoping to get some quick help…

I am trying to implement the respectDoNotTrack setting for my js tracker for my dev environment. Basically i am hoping that the event simply isn’t fired when this setting is set to true.
I have added it to the argmap as directed:

window.Sp('newTracker', 'scala','d3rkrsqld9gmqf.cloudfront.net', {
                                appId: 'cfe23a',
                                platform: 'web',
                                respectDoNotTrack: true
                       });

However, event after this setting, I see the events getting inited and fired (I see pv and pp events in the network logs. I compared the payloads of the data being sent with and without the above setting and see no difference.
Please let me know what I could be doing wrong?

Thanks!


#2

UPDATE on above: OK - I now understand that the respectDoNotTrack setting is based on the user’s browser setting for ‘Do not track’. So it works ONLY if the user has specifically enabled that setting!

In this case, this setting is not going to work for me. Are there any suggestion in the context I am using? ie disable tracking of all events based on an option config setting for the tracker?

Thanks!


#3

Hi @kjain,

What’s the use case? Why have a tracker if you don’t want it to track anything?

Could your objective be achieved by wrapping the tracker in an if statement?

var condition = 0
if (condition > 0) {
window.Sp('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', {
                                appId: 'cfe23a',
                                platform: 'web',
                                respectDoNotTrack: true
                       });
}

#4

Hi Colm

I have implemented a simple custom js wrapper for the sp js tracker which fires for all events. But I don’t want to fire this if I on a test (local, dev) environment since I might not even have the collector and other resources setup for that environment. So I was looking for a quick way to disable the tracking at the init level so I could keep all the methods and calls same for all environments. The only change would be to set the the tracker status when initializing. Similar to how the respectDoNotTrack setting works except that this is now set in the code, rather than a browser setting.

I have already create a setting which is now checked in a condition whenever I init a tracker method, pretty much what you suggested above. This works fine, but I was hoping for a native switch option instead.

Thanks!


#5

Ah I see. Thanks for explaining.

I don’t think there is such a native setting. What I would normally do for this use case is change the appId to dev for my dev environment, and use the same collector (or snowplow mini to test). Then just exclude them from your analysis based on the appId.


#6

As @Colm has mentioned you can either use Snowplow Mini or wrap the block in a condition to fire or alternately if you set an opt out cookie this will block the events from firing.

snowplow("newTracker", "cf", "xx.cloudfront.net", {
  ...
  respectOptOutCookie: true
  ...
});

snowplow('setOptOutCookie', 'optoutcookie');

snowplow('trackPageView');

If you create a cookie called optoutcookie with a non-null value this will prevent the page view from firing. If you remove this cookie events will begin firing again.


#7

Thanks Mike!

Using the optoutcookie seems like a great idea - but it does clutter the environment with a cookie with no other purpose than to suppress the snowplow engine.

Thanks very much!