Delay Firing s.tl Calls in Adobe Analytics

Have you ever had values that you needed to send to Adobe Analytics via a s.tl call but needed to delay the firing of the tag until they were available (but before window onunload)? This post will describe how to delay the firing of a s.tl call so that you can grab those needed values and send over to Adobe accordingly.

What you will need to do is create a setTimeOut function in JavaScript and wrap your s.tl() call within it.  Then set the timeout to be whatever period needed (for this example it will be 3 seconds).  Once three seconds passes, the s.tl call will fire and your tracking will be good to go.  Below is an example of this:

 

setTimeout(function(){
//code for delaying s.tl
var ddrValue = window.location.href;
var datalayerName = digitaldata.getName;

if (ddrValue.indexOf(‘foobar’) > -1) {

//Adobe Analytics s.tl() call

s.linkTrackVars=’eVar90,events’;
s.linkTrackEvents=”event19″;
s.events=”event19″;

s.eVar90 = datalayerName.toLowerCase();
s.tl(true,’o’,’eVar90 tracked’);
}
}, 3000);

That’s really it! By doing this, you will be able to delay your s.tl call as little or as long as you might need so that the data necessary to pass to Adobe will be available.