Created
October 7, 2018 17:31
-
-
Save schalkneethling/3cf78412b10400d9447dee0345e3b277 to your computer and use it in GitHub Desktop.
Code snippets that go along with the blog post ~ Respect User Choice ~ Do Not Track
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// include the helper | |
<script src="js/libs/dnt-helper.js"></script> | |
// If doNotTrack is not enabled, it is ok to add GTM | |
if (!_dntEnabled()) { | |
(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',['YOUR-GTM-ID}}'])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment