Skip to content

Add Plain Analytics

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

Constant

 plugin.tx_cookieconsent.tracking.googleAnalytics = UA-XXXXX

Setup

page.headerData.997 = COA
page.headerData.997 {
	10 = TEXT
	10.value = {$plugin.tx_cookieconsent.tracking.googleAnalytics}
	10.wrap (
<!-- 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=#"></script>
	)
	10.wrap.splitChar = #
	10.required = 1

	20 = TEXT
	20.value = {$plugin.tx_cookieconsent.tracking.googleAnalytics}
	20.wrap (
<!-- Global site tag (gtag.js) - Google Analytics -->
<script data-ignore="1" >
    /* Google Analytics Optout */
    var gaProperty = '#';
    var disableStr = 'ga-disable-' + gaProperty;
   
    function gaOptout() {
        document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
        window[disableStr] = true;
    }
    /* End Google Analytics OputOut */
</script>
	)
	20.wrap.splitChar = #
	20.required = 1

	30 = TEXT
	30.value = {$plugin.tx_cookieconsent.tracking.googleAnalytics}
	30.wrap (
<script data-ignore="1" data-cookieconsent="statistics" type="text/plain">
    /* Google Analytics Optout */
    var gaProperty = '#';
    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>
	)
	30.wrap.splitChar = #
	30.required = 1
}

Clone this wiki locally