How to block Klaviyo from collecting information?
How the script works?
We are setting the Klaviyo cookie __kla_off to true, which should stop Klaviyo from tracking onsite activity data, if the customer has opted out of the Marketing cookie group through our app.
For additional reference on how the script works, feel free to check the documentation for Klaviyo here - About Cookies in Klaviyo
Applying the script
In order to block the tracking from Klaviyo so that no information is being collected if a customer has opted out of the **Marketing **cookie group, you would need to add an additional script in your main theme file. Here are the steps that you would need to follow:
- Open Shopify Admin.
- Click on Online Store link in the left menubar.
- Click on the Action **dropdown button and select **Edit Code from there.
- A new page will open with a list of files on the left side of the screen. Open the theme.liquid file.
- Find the closing </head> tag there.
- When you do, you can copy and add the following snippet __before __ the closing </head> tag:
<!-- Klaviyo integration script from Consentmo GDPR app -->
<script id="consentmo-klaviyo-integration-script">
function checkConsentForKlaviyo(isMarketingEnabled) {
if (isMarketingEnabled) {
console.log('exec klaviyo');
document.cookie = "__kla_off=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
} else {
console.log('blocked klaviyo');
document.cookie = "__kla_off=true";
}
}
document.addEventListener('consentmoSignal_onLoad', function(eventData) {
const csmLoadSignal = eventData.detail || {isActive:false};
if (!csmLoadSignal.isActive) {
checkConsentForKlaviyo(true);
} else {
document.addEventListener('consentmoSignal', function(event) {
const csmPreferences = event.detail.preferences;
checkConsentForKlaviyo(csmPreferences.marketing);
});
}
});
</script>
- Click on the **Save **button.
Adding the Klaviyo cookie
Once you’ve successfully added the script, you need to add the Klaviyo cookie __kla_id into our app by navigating to Cookie bar settings tab > Management section.
- You can add the cookie from the Cookies management table, as shown below:
The __kla_id cookie can be added with the following details:
- Cookie provider - Klaviyo
- Cookie description - This cookie is used to collect information about the visitor's behaviour. This information will be stored on the website for internal use.
- **Category **- Marketing
- **Duration **- 2 years
Need help?
If you have any questions, don't hesitate to contact our support team at: support@consentmo.com or from the Chat button at the bottom right corner of your browser.
Updated on: 05/06/2025
Thank you!