Attentive integration
Attentive Integration
How it works
This integration prevents the Attentive tag from loading before the customer gives the required cookie consent.
When Marketing cookies are accepted, the script loads the Attentive tag and allows Attentive to initialize on the store.
When Marketing cookies are rejected, the Attentive tag will not be executed.
Integration Steps
- Open Shopify Admin.
- Click on Online Store from the left sidebar.
- Click on the Actions dropdown button and select Edit code.
- Open the
theme.liquidfile from the Layout section. - Locate the opening
<head>tag. - Add the following integration script inside the
<head>section of the file:
<!-- Attentive integration script from Consentmo GDPR Compliance App -->
<script id="consentmo-attentive-integration-script">
let isAttentiveExecuted = false;
function loadScriptOnce(src, selectorCheck, callback) {
const existingScript = document.querySelector(selectorCheck || 'script[src="' + src + '"]');
if (existingScript) {
console.log('[Consentmo] Script already exists:', src);
if (typeof callback === 'function') {
callback();
}
return;
}
const script = document.createElement('script');
script.src = src;
script.async = false;
script.onload = function () {
console.log('[Consentmo] Script loaded:', src);
if (typeof callback === 'function') {
callback();
}
};
script.onerror = function () {
console.warn('[Consentmo] Failed to load script:', src);
};
document.head.appendChild(script);
console.log('[Consentmo] Script appended after Marketing consent:', src);
}
function executeAttentive() {
if (isAttentiveExecuted) {
return;
}
isAttentiveExecuted = true;
console.log('[Consentmo] Marketing consent granted. Loading Attentive tag.');
loadScriptOnce(
'https://cdn.attn.tv/StoreName/dtag.js?shop=StoreName.myshopify.com',
'script[src*="cdn.attn.tv/StoreName/dtag.js"]',
function () {
console.log('[Consentmo] Attentive dtag finished loading.');
}
);
}
function getCookieValue(cookieName) {
const match = document.cookie.match(
new RegExp('(?:^|;\s*)' + cookieName + '=([^;]*)')
);
return match ? decodeURIComponent(match[1]) : null;
}
function checkConsentForAttentive(additionalChecks = 0) {
const disabledPreferences = getCookieValue('cookieconsent_preferences_disabled');
if (disabledPreferences !== null) {
if (disabledPreferences.indexOf('marketing') === -1) {
executeAttentive();
} else {
console.log('[Consentmo] Attentive blocked: Marketing consent not granted.');
}
return;
}
if (additionalChecks > 0) {
setTimeout(function () {
checkConsentForAttentive(additionalChecks - 1);
}, 500);
}
}
document.addEventListener('consentmoSignal', function (eventData) {
if (
eventData &&
eventData.detail &&
eventData.detail.preferences
) {
const data = eventData.detail.preferences;
console.log('[Consentmo] consentmoSignal received:', data);
if (data.marketing) {
executeAttentive();
} else {
console.log('[Consentmo] Attentive blocked from consentmoSignal: Marketing consent not granted.');
}
}
});
window.addEventListener('load', function () {
checkConsentForAttentive(10);
});
checkConsentForAttentive(10);
</script>
- Replace
StoreNamewith the correct store-specific Attentive value and Shopify store name.
Example format:
https://cdn.attn.tv/StoreName/dtag.js?shop=StoreName.myshopify.comFor example, if the Attentive tag provided by Attentive uses a different value before /dtag.js, make sure to use the exact value from their tag.
- Save the changes.
Important Attentive setup
Before using this integration, make sure the automatic Attentive app embed is disabled.
To check this:
- Go to Online Store.
- Click Customize on the active theme.
- Open App embeds.
- Locate the Attentive app embed.
- Disable it and save the theme.
This step is important because if Attentive is still loading through the app embed, it may load before consent and bypass the Consentmo-controlled integration script.
Testing the integration
After adding the script:
- Clear the store cookies or open the store in an incognito window.
- Open the browser Developer Tools.
- Go to the Network tab.
- Filter by:
attn- Before consent, the Attentive requests should not load.
- Accept Marketing cookies.
- The Attentive script should load after consent is granted.
Need help?
In case you need any assistance, please reach out to our support team via live chat or at support@consentmo.com.
Updated on: 25/07/2026
Thank you!
