tracking - Load Google Tag Manager Synchronously -


i have searched google tag manager (gtm) documentation , did not find addressing issue. i'm working affiliate network wants tracking pixel loaded synchronously ensure fires before content of page loads. applies our order confirmation page. we've implemented gtm can launch , fix tags in 5 minutes versus 2 weeks.

gtm installed @ top of our order confirmation page , loads tags asynchronously know affiliate networks' tags loading networks still concerned data may lost. gtm doesn't have options or documentation indicate possible load script synchronously notice j.async=true name-value pair in code.

if change part of code j.async=false, code load synchronously or break it?

here's full code reference.

<!-- google tag manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=gtm-xxxx" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new date().gettime(),event:'gtm.js'});var f=d.getelementsbytagname(s)[0], j=d.createelement(s),dl=l!='datalayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentnode.insertbefore(j,f); })(window,document,'script','mynewname','gtm-xxxx');</script> <!-- end google tag manager --> 

the article on cardinal path great learning how setup synchronous tags.

however, concern ensuring there no lost data, highlight mickael's comment @ bottom of article. since datalayer.push might not complete before gtm.dom event occurs, should include custom event in datalayer.push not relying on gtm.dom fire tags.

here example tag custom event specific page load.

tag name: pageload

tag type: custom html tag

html:

<script type="text/javascript"> var tid = setinterval( function () {     if ( document.readystate !== 'complete' ) return;     clearinterval( tid );            datalayer.push({ "event": "pageloaded" }); }, 100 ); </script> 

add following firing rule.

rule name: pages

condition: {{url}} matches regex .*

then, on affiliate tags want fired, have include custom event (i.e. pageloaded) condition on firing rule. in example, condition be: {{event}} equals pageloaded


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -