Skip to content

Instantly share code, notes, and snippets.

@samba
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samba/f45fcc1b93f5a98e9fcf to your computer and use it in GitHub Desktop.
Save samba/f45fcc1b93f5a98e9fcf to your computer and use it in GitHub Desktop.
GTM MultiLoader
<script>
var GTMContainerIDs = ['GTM-XXXXX', 'GTM-YYYYY' /* Add your container ID(s) here */ ];
(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