This guide walks you through implementing Termly’s Consent Management Platform consent tracking and registering it with Tealium’s custom CMP interface.
Step 1: Capture Termly Consent State
The script allows Tealium to reference the current consent preferences when evaluating tag triggers.
function onTermlyLoaded() { Termly.on('consent', ({ consentState }) => { initializeTeamliumCmpIntegration(consentState) }) } <script type="text/javascript" src="https://app.termly.io/resource-blocker/YOUR_WEBSITE_ID?autoBlock=on" onload="onTermlyLoaded()" ></script>
Step 2: Register Termly with Tealium as a Custom CMP
Using the following script, map Termly’s consent categories to Tealium iQ’s consent groups. This creates a full connection between Termly and Tealium’s Consent Manager.
function onTermlyLoaded() { Termly.on('consent', ({ consentState }) => { initializeTeamliumCmpIntegration(consentState) }) } function initializeTeamliumCmpIntegration(consentState) { window.tealiumCmpIntegration = { ...window.tealiumCmpIntegration, cmpName: 'Termly CMP Integration', cmpIntegrationVersion: 'v1.1.0', cmpFetchCurrentConsentDecision: () => (consentState || {}), cmpFetchCurrentLookupKey: () => 'termly-consent-v1', cmpCheckIfOptInModel: () => true, cmpCheckForExplicitConsentDecision, cmpCheckForWellFormedDecision, cmpConvertResponseToGroupList, cmpCheckForTiqConsent, cmpAddCallbackToTriggerRecheck, } const consentCategories = [ 'advertising', 'analytics', 'essential', 'functional', 'performance', 'social_networking', 'unclassified', ] function cmpCheckForWellFormedDecision(cmpRawOutput) { return typeof cmpRawOutput === 'object' } function cmpCheckForExplicitConsentDecision(cmpRawOutput) { if ( !cmpRawOutput ) { return false } return consentCategories .some((category) => cmpRawOutput[category] != null) } function cmpConvertResponseToGroupList(cmpRawOutput) { if ( !cmpRawOutput ) { return [] } return consentCategories .filter((category) => cmpRawOutput[category]) } function cmpAddCallbackToTriggerRecheck(triggerRecheck) { window.Termly?.on('consent', () => { triggerRecheck() }) } function cmpCheckForTiqConsent(cmpRawOutput, tiqGroupName) { if ( !cmpCheckForWellFormedDecision(cmpRawOutput) ) { return false } const allowedGroups = cmpConvertResponseToGroupList(cmpRawOutput) return allowedGroups.includes(tiqGroupName) } }
Step 3: Map Consent Categories
Below is a reference for how Termly’s cookie categories map to Tealium iQ consent groups:
Termly Category | Tealium iQ Group |
---|---|
performance |
performance |
analytics |
analytics |
advertising |
marketing |
social_networking |
social |
essential |
essential (optional) |
unclassified |
unclassified (optional) |