How to bypass analytics blockers like Ghostery or uBlock Origin

According to the statistics for this blog, up to 50% of my visitors have some sort of privacy blocker. I wanted to have real information about how visitors interact with my blog, which is why I needed to bypass them.

I use two analytics softwares, Google Analytics and Matomo (formerly Piwik), but I only bypass analytics blockers with the later one. Traying to do so with Google Analytics or any other hosted service usually requires some sort of complicated proxying which I tried and found either not to be fully reliable or to be overly complicated. While doing it with Matomo (Piwik) does not require any hacks, the standard installation is all you need.

To do so I have a Matomo (Piwik) installation which you can set up by following this tutorial: How to self-host and deploy Piwik using Docker with https support, and make sure you do not use piwik or matomo in the domain or subdomain or it might get blocked.

Once you have your Matomo installation, modify the tracking code it gives you by replacing piwik.php and piwik.js with js/, one occurrence each.

If your original code looks something like this:

<!-- Matomo -->
<script type="text/javascript">
  var _paq = _paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//mtm.domain.com/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

Your changes should be applied on lines 9 and 12, and your modified code should look like this:

<!-- Matomo -->
<script type="text/javascript">
  var _paq = _paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//mtm.domain.com/";
    _paq.push(['setTrackerUrl', u+'js/']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'js/'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

This will bypass pretty much every blocker.

Jan. 14, 2018

Comments