|
|
Subscribe / Log in / New account

Privacy-preserving Google Analytics

Privacy-preserving Google Analytics

Posted Jun 17, 2020 21:32 UTC (Wed) by dw (subscriber, #12017)
In reply to: Matomo by dw
Parent article: Lightweight alternatives to Google Analytics

It's worth mentioning the possibility of removing some of the sting from Google Analytics using the measurement protocol and a local copy of analytics.js. You host a proxy script that forwards the hit on to GA, after making any desirable privacy-preserving changes, such as lopping off some of the IP address (rather than rely on the equivalent Google setting). On the client, configuring analytics.js with a custom sendHitTask delivers data to the script.

For completeness, the client juju is simply:

    ga('create', 'UA-XXXXXXX-1', 'auto');
    ga(function(tracker) {
        tracker.set('sendHitTask', function(model) {
            var xhr = new XMLHttpRequest();
            xhr.open('POST', '/wrapper-script');
            xhr.send(model.get('hitPayload'));
        });
    });

This also creates an opportunity for logging the hit data, so you get the best of both worlds: hassle freedom of GA with all the raw GA preserved should you wish to migrate to another solution in future.

Finally, since the entirety of the data received by Google is controlled, and if you're sufficiently paranoid, it's even possible to anonymize the domain being tracked.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds