Using Axeptio Consent Manager CMP with Matomo Tag Manager
Integrating the Axeptio Consent Manager (CMP) with Matomo Tag Manager allows you to manage cookies and tracking based on visitor consent without embedding the Axeptio script directly into your website.
By using the Axeptio Tag in Matomo Tag Manager, you can centralise consent management, making it easier to dynamically handle cookie preferences. This ensures Matomo only tracks visitors who have granted the necessary consent. Read more on the ePrivacy Directive.
This guide explains how to integrate Matomo Tag Manager with Axeptio CMP. We recommend reading it together with the Matomo Tag Manager and Consent Managers (CMP) Integration Guide.
Requirements
Check the following is set up before starting the integration process:
- You have an Axeptio account with a configured cookie consent banner.
- The Matomo Tag Manager container code has been installed on your website.
- Check the basics requirements are completed for the Tag Manager configuration.
Define the Axeptio Tag
Note: If you are an existing Axeptio user, remove the Axeptio script from your website code before implementing this tag.
- In Matomo Tag Manager, navigate to Tags and click Create New Tag.
- Choose the Axeptio Tag and provide a descriptive name.
- Provide the Project ID. This is found on your Axeptio admin homepage.
- In the section, Configure when the tag should do this, choose the Pageview trigger that will execute the tag when a visitor views your website pages.
- Click Create New Tag to save the Axeptio tag.
Create a Custom HTML Tag to apply cookie consent
To explicitly request consent to start tracking with cookies, you will need to create a Custom HTML tag to include the Matomo script that manages consent updates from Axeptio.
If the visitor gives consent, Matomo will start tracking using cookies. If consent is denied or revoked, Matomo will track without cookies and any existing Matomo cookies are removed.
- In Matomo Tag Manager, navigate to Tags and click Create New Tag.
- Choose the Custom HTML Tag type and provide a descriptive name.
- Copy the script below and paste it into the Custom HTML field.
- Set the Position to Head Start. This defines where the code gets inserted into the website’s code.
<script>
window._axcb = window._axcb || [];
window._mtm = window._mtm || [];
window._axcb.push(function (sdk) {
sdk.on("cookies:complete", function (choices) {
let axeptio_Matomo = [];
// Process consent choices
for (let vendor in choices) {
if (vendor !== "$$completed" && choices[vendor] === true) {
// Trigger an activation event for each vendor
_mtm.push({ event: `axeptio_activate_${vendor}` });
// Track Matomo consent
if (vendor.toLowerCase() === "matomo") {
axeptio_Matomo.push(vendor);
}
}
}
// Add the Matomo consent status to the data layer
_mtm.push({ axeptio_Matomo });
// Handle Matomo tracking based on consent
if (axeptio_Matomo.length > 0) {
enableMatomo();
} else {
disableMatomo();
}
});
});
function enableMatomo() {
_paq.push(['rememberCookieConsentGiven']);
_paq.push(['setConsentGiven']);
}
function disableMatomo() {
_paq.push(['forgetCookieConsentGiven']);
_paq.push(['deleteCookies']);
}
</script>
In the section, Configure when the tag should do this, link a DOM Ready Trigger and save the tag.
Note:
- The Matomo Analytics Tag must be defined and linked to the Matomo Configuration Variable and Pageview trigger.
- The option, Require Cookie Consent must be enabled in the Matomo Configuration Variable.
Create a Custom HTML Tag to apply tracking consent
To explicitly request consent to start tracking, you will need to create a Custom HTML tag to include the Matomo script that manages consent updates from Axeptio. No tracking occurs unless consent is given.
When the user gives consent, Matomo will start tracking; if the user denies or revokes consent, Matomo will stop tracking and remove any existing Matomo cookies.
- In Matomo Tag Manager, navigate to Tags and click Create New Tag.
- Choose the Custom HTML Tag type and provide a descriptive name.
- Copy the script below and paste it into the Custom HTML field.
- Set the Position to Head Start. This defines where the code gets inserted into the website’s code.
<script>
window._axcb = window._axcb || [];
window._mtm = window._mtm || [];
window._axcb.push(function (sdk) {
sdk.on("cookies:complete", function (choices) {
let axeptio_Matomo = [];
// Process consent choices
for (let vendor in choices) {
if (vendor !== "$$completed" && choices[vendor] === true) {
// Trigger an activation event for each vendor
_mtm.push({ event: `axeptio_activate_${vendor}` });
// Track Matomo consent
if (vendor.toLowerCase() === "matomo") {
axeptio_Matomo.push(vendor);
}
}
}
// Add the Matomo consent status to the data layer
_mtm.push({ axeptio_Matomo });
// Handle Matomo tracking based on consent
if (axeptio_Matomo.length > 0) {
enableMatomo();
} else {
disableMatomo();
}
});
});
function enableMatomo() {
_paq.push(['setConsentGiven']);
}
function disableMatomo() {
_paq.push(['forgetConsentGiven']);
}
</script>
In the section, Configure when the tag should do this, link a DOM Ready Trigger and save the tag.
Note:
- The Matomo Analytics Tag must be defined and linked to the Matomo Configuration Variable and Pageview Trigger.
- The option, Require tracking consent must be enabled in the Matomo Configuration Variable.
Test and Publish
Once you have integrated your consent manager with Matomo Tag Manager, it is recommended to test accepting, rejecting and changing consent preferences to ensure that Matomo correctly manages cookies and tracking.
Learn more about testing and validating consent manager integrations.
Disclaimer: The use of any third-party tools (plugins, extensions, platforms, APIs, widgets, etc.) is at your own risk. Matomo does not own, control, maintain or support any third-party tools that integrate with our product. We recommend checking your privacy setup is correctly configured across your environment when using any third party tools.