1
Create a Custom HTML tag
In your container, go to Tags → New → Tag Configuration → Custom HTML and paste:Replace
cbh_pk_your_publishable_key with your property’s publishable key.2
Set the trigger
Choose Initialization – All Pages (or All Pages if your container doesn’t have the initialization trigger). The SDK should load on every page where you’ll use it.If you only use the SDK on specific pages (e.g.
/deals), use a Page View trigger with a path condition instead.3
Preview, then publish when ready
Use GTM’s Preview mode to test on your site. On an allowed origin, open the browser console and confirm:Publish the container only after you’ve verified the integration — the SDK won’t load for visitors until you do.
Using the SDK from other tags
Other Custom HTML tags can use the SDK too. Because tag execution order isn’t guaranteed, always wait for readiness:dataLayer so they can drive other GTM tags.
Notes
- GTM’s Custom HTML tags run as regular page scripts, so the SDK behaves identically to a direct install. The same allowed-origin and CSP rules apply.
- The
document.currentScriptthe SDK readsdata-keyfrom is the element created above, not the GTM container script, so auto-initialisation works normally. - If your GTM setup uses a consent mode that delays tags until consent is granted, the SDK will simply initialise later and
cbh:readywill fire then. Code that follows the readiness pattern above handles this automatically.