Closed Ghaleb-alnakhlani closed 3 years ago
This is mentioned in the README (Features): "Already accepted cookies are not deleted, Pardot scripts will be removed from the DOM. Google Analytics script will not be deleted. Instead it will be deactivated as described in Google Analytics Opt-Out. Further read Google Developers Guide (https://developers.google.com/analytics/devguides/collection/gtagjs/user-opt-out). "
Hi Onza does this also apply to deny option? what u suggest to do if i want to stop google tracking?
If you click on "deny", a cookie will be set that you have refused cookies. Otherwise you would have to display the cookie consent banner again on every further subpage.
Yes i noticed it works exactly how you describe it. However, shouldn`t the tracking stop by the site when i click on deny? I am not exactly sure how the cookie things works in general?
The question is, who is tracking the site? And how to test?
First remove all cookies from the site (via chrome developer tools). Then reload the page. Now the cookie consent banner should be shown. There mustn't be any cookie installed for the site. * Click on deny. There is one cookie from cookie consent. It just stores, that cookies are denied. It can't be used to track any user.
If you accept the cookies, then some google cookies are stored.
* If there is any cookie, you are already tracking. If you use GoogleAnalytics then ensure, you do not include the script (https://www.googletagmanager.com/gtag/js?id={gtag-id}) anywhere. This will be done by our script, when the user clicks on accept.
Do you use any other tracking mechanism? If yes, which one and how do you install it on your site?
@robindanzinger this really detailed explanation. I did exactly what you have mentioned and i realized even when i click deny there are some other cookies with ga....
it is because i have GoogleTagManger script in the head of every page. this is the reason
so in this case what should i do remove the scripts from the pages? if yes where should i include them in the CookieConsent.js
@Ghaleb-alnakhlani , yes, that's right, if you use the gtag script https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID)*. Just remove it from all your scripts. It will be automatically added by the CookieConsent script. (of course only when the user accepts cookies).
Make sure, that you replace the gt-ID (GA_MEASUREMENT_ID) in the CookieConsent.js file. https://github.com/onza/CookieConsent/blob/f6fe500c8439528d38f71d223101d7470280205b/src/js/CookieConsent.js#L12
And adapt the options object in CookieConsent.js (e.g. remove pardot in line 20 if you do not use pardot): https://github.com/onza/CookieConsent/blob/f6fe500c8439528d38f71d223101d7470280205b/src/js/CookieConsent.js#L20
* although the script is located under googletagmanager.com, it is not GoogleTagManager but GoogleAnalytics. GoogleTagManager works a littlebit different.
@robindanzinger I made the changes and disabled the pardot
basically i removed this line cookies: ['googlesitetag', 'pardot'],
but i fot this error now when ever i click on accept or deny and the banner doesnt hide
you should remove pardot, not the line:
before
cookies: ['googlesitetag', 'pardot'],
after
cookies: ['googlesitetag'],
Sorry silly mistake Now, no matter if i click accept or deny it doesnt track, it suppose to start tracking when i click accept
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','.........ID');</script>
this is the previous script that i was using ?
is it because of what u have mentioned previously ? "* although the script is located under googletagmanager.com, it is not GoogleTagManager but GoogleAnalytics. GoogleTagManager works a littlebit different."
I guess i am using GoogleTagManager the ID start with GTM
yes, you use GoogleTagManager, not GoogleAnalytics.
You have to do some work:
Remove the content of the function disableGooglesitetag
before:
https://github.com/onza/CookieConsent/blob/f6fe500c8439528d38f71d223101d7470280205b/src/js/CookieConsent.js#L148-L155
after:
function disableGooglesitetag() {}
Then place your previous script in function enableGooglesitetag() {...
After:
function enableGooglesitetag() {
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','.........ID');
}
@robindanzinger thank you this solved my problem now it is working as expected
Hi again, When i click on deny i see the website still tracking me? How i know if deny is working ? do i need to make some changes to the original code?