Do you want to notify your Google Tag Manager container when all the cookies from a step have been accepted, in addition to the events sent for each cookie? Here's how to do it!
First, you will need to load this script:
window.dataLayer = window.dataLayer || [];
window._axcb = window._axcb || [];
window._axcb.push(function(sdk){
sdk.on('cookies:complete', function(choices){
const steps = sdk.config.cookies[0].steps;
const cookiesSteps = steps.splice(1, steps.length);
cookiesSteps.forEach(step => {
const vendors = step.vendors;
let allAccepted = true;
vendors.forEach(vendor => {
const choice = choices[vendor.name];
if(choice === false || choice === undefined){
allAccepted = false;
}
});
if(allAccepted === true){
dataLayer.push({'event': step.name + '_accepted'});
}
});
});
});
You can add this script after your Axeptio script, or in a separate <script> tag. Since this script is asynchronous, you don't need to load it in a specific place.
Once the script is added, the events will be automatically sent to Google Tag Manager, based on the identifier of the accepted step. For example:
Here, the sent event will be "analytics_accepted".