Skip to content

Add Plain Analytics

Dirk Persky edited this page Sep 17, 2020 · 8 revisions

page.headerData.997 = TEXT
page.headerData.997.value(
<!-- Global site tag (gtag.js) - Google Analytics -->
<script data-ignore="1" data-cookieconsent="statistics" type="text/plain" async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXX"></script>
<script>

    /* Google Analytics Optout */
    var gaProperty = 'UA-XXXXX';
    var disableStr = 'ga-disable-' + gaProperty;

  function gaOptout() {
        document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
        window[disableStr] = true;
    }

</script>
<script data-ignore="1" data-cookieconsent="statistics" type="text/plain">

    /* Google Analytics Optout */
    var gaProperty = 'UA-XXXXX';
    var disableStr = 'ga-disable-' + gaProperty;
    if (document.cookie.indexOf(disableStr + '=true') > -1) {
        window[disableStr] = true;
    }

     /* Google Analytics */
	window.dataLayer = window.dataLayer || [];
	function gtag(){dataLayer.push(arguments);}
	gtag('js', new Date());

	gtag('config', gaProperty, { 'anonymize_ip': true });
    /* End Google Analytics */
</script>
)

Clone this wiki locally