Skip to content

Instantly share code, notes, and snippets.

@samba
Last active July 5, 2017 22:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samba/0bf5fe5d56ef03489101 to your computer and use it in GitHub Desktop.
Save samba/0bf5fe5d56ef03489101 to your computer and use it in GitHub Desktop.
GTM Container Snippet for HubSpot
<!-- Google Tag Manager loader; customized by Analytics Pros [analyticspros.com] -->
<script>
/* Update these for your GTM container(s); be sure they're unique, occurring only once each, not duplicated */
var GTMContainerIDs = ['GTM-XXXXX', 'GTM-YYYYY' ];
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'platform': 'hubspot' // Update this value to reflect other platforms
});
(function(w,d,s,l,i,j,f,dl,k,q){
w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
f=d.getElementsByTagName(s)[0], k=i.length;q='//www.googletagmanager.com/gtm.js?id=@&l='+(l||'dataLayer');
while(k--){j=d.createElement(s);j.async=!0;j.src=q.replace('@',i[k]);f.parentNode.insertBefore(j,f);}
}(window,document,'script','dataLayer',GTMContainerIDs));
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment