Firefox do not track will break your Javascript

TL;DR

Gogobot like many other websites uses Google Analytics and Mixpanel to track visits on webpages, along with stats like bounce rate, time on page etc…

Firefox recently released a Do Not Track feature on Private Browsing windows.

This created a lot of problems for us and I believe it has the potential to create problems for your website as well.

Technical details

When this feature is enabled, Firefox blocks known tracking websites such as Mixpanel and Google Analytics.

However, it does not handle what’s happening if you call any of the code in those libraries.

We use Require.js in order to manage dependencies, here’s some sample code from the Gogobot website.

if (review_props) {
    review_props['Type of review'] = 'Review';
    review_props['Item ID'] = model.get("place_id");
    review_props['Item name'] = "null";
    review_props['New or edit'] = "null";
    mixpanel.track("Write a review", review_props);
}

mixpanel here is counting on the mixpanel library to load. However if it doesn’t load (say in the case of Firefox blocking the load) mixpanel.track will fail and subsequently, all of your JS will crumble.

The solution

First, this firefox “block” is pretty easy to bypass. Since it’s really only counting on the domain of the tracking JS and not on the content of the file you can just proxy from your domain through Nginx.

This solution is only temporary since we are implementing the do not track and will fall back gracefully.

Checking if the Do Not Track header is set will basically load a blank js file for Mixpanel that implements the same interface but does nothing.

Same for Google Analytics and any other tracking you are using.

Blocking the domain is not blocking tracking

Firefox is really not communicating this correctly IMHO, blocking the domain of known trackers is not really blocking tracking. Chrome addons that claim to block tracking are doing the same thing.

Just because you block cdn.mxpanel.com doesn’t really mean you blocked the tracking at all.

For us, respecting our users and their wishes is super important so we are implementing it but others just might leave the proxy there forever without really caring.

Check your pages

I encourage you to check your pages to make sure they work with the setting on, you might be surprised at what’s breaking.

Lesson learned

The lesson learned by this is to check whether you have the lib loaded by the
CDN. This can be blocked by many things, even user network.

It looks like this

track: function(event, properties) {
    if(typeof mixpanel !== "undefined") {
        event = event || "";
        mixpanel.track(this.trackingTag + " " + event, properties);
    }
}

Instead of calling mixpanel.track everywhere we simply call track which is
part of the base view javascript, this will gracefully fall back in case
mixpanel didn’t load. Same for Google Analytics.