Google Analytics

bootScore allows you to write Javascript in widgets. So it is the best and easiest way to place the tracking code in a footer widget.

Here is a GDPR-ready variant that allows the user to turn off the tracking themselves.

    var gaProperty = 'UA-123456789-X';
    var disableStr = 'ga-disable-' + gaProperty;
    if (document.cookie.indexOf(disableStr + '=true') > -1) {
        window[disableStr] = true;

    function gaOptout() {
        document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
        window[disableStr] = true;
        // alert('Google Analytics has been disabled'); 
    (function(i, s, o, g, r, a, m) {
        i['GoogleAnalyticsObject'] = r;
        i[r] = i[r] || function() {
            (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date();
        a = s.createElement(o),
            m = s.getElementsByTagName(o)[0];
        a.async = 1;
        a.src = g;
        m.parentNode.insertBefore(a, m)
    })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

    ga('create', 'UA-123456789-X', 'auto');
    ga('set', 'anonymizeIp', true);
    ga('send', 'pageview');



  1. Replace UA-123456789-X in line 2 and 25 with your own Tracking-ID
  2. Place code in a HTML widget in footer position.


This step allows the user to switch Google Analytics off by clicking a link. A cookie is set to prevent further tracking. Paste following paragraph into a HTML block inside your privacy statement:

<p>Alternatively it is possible to prevent future analysis of your page visit by Google Analytics by clicking the below link. Clicking that link sets a so-called opt-out cookie, which has the effect of preventing the analysis of your visit to our website in future. <a onclick="alert('Google Analytics has been disabled');" href="javascript:gaOptout()"><strong>Activate opt-out cookies for Google Analytics!</strong></a></p>


  1. Open Google Chrome Developer Console and go to your privacy page.
  2. Open the Applications/Cookies Tab in the Console.
  3. Click on the link from the pasted paragraph. An Alert should be displayed “Google Analytics has been disabled”
  4. Reload the page
  5. There must be a new Cookie ga-disable-UA-123456789-X (Your Tracking-ID).

Leave a Comment

Cookies help us deliver our services. By using our services, you agree to our use of cookies. More Information