Closed Bug 1515144 Opened 2 years ago Closed 2 years ago

Prevent Google Analytics script from being loaded when DNT:1 so that Tracking Protection doesn't have to block it

Categories

(bugzilla.mozilla.org :: Extensions, defect)

Staging
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: jan, Assigned: kohei.yoshino)

Details

(Keywords: nightly-community, ux-trust)

Attachments

(2 files)

I found this always a bit strange and never filed a bug about it so far, sorry.
BMO respects DNT. Even when Tracking Protection is disabled, we always take DNT into account.

https://github.com/mozilla-bteam/bmo/blob/master/extensions/GoogleAnalytics/web/js/analytics.js
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → WORKSFORME
(In reply to Kohei Yoshino [:kohei] (Bugzilla UX) (FxSiteCompat) from comment #1)
> BMO respects DNT. Even when Tracking Protection is disabled, we always take DNT into account. 

Yes, but "process less data" is not the same as "Do not track" with the european legal meaning of Opt-Out and Mozilla's strictness.

When Tracking Protection is disabled there is still a connection made to analytics.google.com even when sending a DNT:1 header. There shouldn't be one in this case. It is unexpected that tracking protection still has to block a tracker on a Mozilla website regardless of prior user choice.
Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---
So we would have to check either client-side or server-side for the DNT:1 header and to not deliver or execute this line:
https://github.com/mozilla-bteam/bmo/blob/f8a6f476946b994f7f555da0ebbb14fc57a4f9c4/extensions/GoogleAnalytics/template/en/default/hook/global/header-additional_header.html.tmpl#L23
I have never seen a standard way to load Google Analytics on Mozilla properties, but yeah, it’s possible to insert the async <script> only when DNT is disabled. The official code snippet is here:

https://developers.google.com/analytics/devguides/collection/analyticsjs/
Assignee: nobody → kohei.yoshino
Status: REOPENED → ASSIGNED
In the template, this would be [% IF c.req.headers.dnt %] ... [% END %]
I thought we had a cross-Mozilla standard for implementing this, because when we re-introduced GA, we discussed making certain that no-GA code was loaded if DNT:1?
(In reply to Dylan Hardison [:dylan] (he/him) from comment #5)
> In the template, this would be [% IF c.req.headers.dnt %] ... [% END %]

We could probably do it. Since older versions of IE and Firefox showed weird behaviour, we are using a DNT helper script developed for www.mozilla.org. But these oldies are no longer supported in Bugzilla, we can just rely on the HTTP header and remove the helper.
Component: General → Extensions: Other
Summary: Could BMO respect the DNT:1 header so that Tracking Protection doesn't have to block Google Analytics? → Prevent Google Analytics script from being loaded when DNT:1 so that Tracking Protection doesn't have to block it
Attached file GitHub Pull Request
Merged to master.
Status: ASSIGNED → RESOLVED
Closed: 2 years ago2 years ago
Resolution: --- → FIXED

Verified, it has been deployed. Thanks :)

Status: RESOLVED → VERIFIED
Component: Extensions: Other → Extensions
You need to log in before you can comment on or make changes to this bug.