Reputation: 1
I have set up Cookiebot for an ecommerce site and also have setup Pageviews when consent is given (which works only when the user refreshes the page or goes on to the next one). However, the page on which the user accepts his cookies isn't being tracked. Is there a way to trigger a pageview on the same page where the user accepts the cookies?
I believe that this is a common problem, but I can't find information about this online or I am searching the wrong way. Any ideas will be helpful, thanks.
Upvotes: 0
Views: 2188
Reputation: 61
There are likely several ways to solve it, depending on your e-commerce setup. What we have done with the help of dataLayer pushes:
Pageview tag fires after either trigger runs:
The Trigger group consists of two events that both have to be true:
You get "Cookie Consent" variable through the "Cookiebot Consent State" variable template.
With this we solve two scenarios:
Upvotes: 1
Reputation: 475
Cookiebot's documentation has this example about halfway down the "setting up Cookiebot" page:
CookiebotOnAccept The event is triggered if the user accepts the use of cookies. The event is also triggered if the user has consented at an earlier visit to the website.
Example: Load marketing cookies if the user has accepted
<script type="text/javascript"> window.addEventListener('CookiebotOnAccept', function (e) { if (Cookiebot.consent.marketing) { //Execute code that sets marketing cookies } }, false); </script>
You should just be able to put your GTM snippet in there and it will load when the user clicks accept, and when they've already accepted.
Upvotes: 1