codefog/contao-cookiebar

Opt-in variant -> no data in Google Analytics

Closed this issue · 3 comments

Hello codefog,

I would like to implement the "Opt-In" variant and have accordingly inserted the following line in the "analytics_google.html5" template:

window['ga-disable-'] = !localStorage.getItem('COOKIEBAR_ANALYTICS');

However, no data has been recorded in the last few days. What can be the problem here? Implemented on www.federleicht.cc

Thanks, Markus

Your implementation looks correct, although there is some extra code that might prevent GA from working:

<script>var gaProperty='UA-30338188-13';var disableStr='ga-disable-'+gaProperty;if(document.cookie.indexOf(disableStr+'=true')>-1){window[disableStr]=!0}
function gaOptout(){document.cookie=disableStr+'=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';window[disableStr]=!0}</script>

thank you, that's it!
The script was responsible for setting an opt-out cookie: https://erdmann-freunde.de/logbuch/analytics-contao-datenschutz/

Is there perhaps other solution to get an opt-out-link?

The extension does not provide that out of the box but you should be able to achieve that using some simple JS. All you have to do is to adjust the localStorage item COOKIEBAR_ANALYTICS.