Skip to content

Instantly share code, notes, and snippets.

View stefanatcroud's full-sized avatar

Stefan Holmes stefanatcroud

View GitHub Profile
@shadybones
shadybones / CMAPI_Integration.js
Last active January 29, 2024 08:59
Partial integration between the TrustArc Consent Manager API and Google Tag Manager. This code allows for GTM event-based tag firing solution.
var __dispatched__ = {}; //Map of previously dispatched preference levels
/* First step is to register with the CM API to recieve callbacks when a preference update occurs
You must wait for the CM API (PrivacyManagerAPI object) to exist on the page before registering
*/
var __i__ = self.postMessage && setInterval(function(){
if(self.PrivacyManagerAPI && __i__){
var apiObject = { PrivacyManagerAPI:
{ action:"getConsentDecision",
timestamp: new Date().getTime(),