How can I delay s.t call in adobe DTM?

Viewed 1137

I have created one event based rule-

In adobe analytics portion I have set s.t call but how can I delay this call - “s.t call”

Here i have attached one screenshot where i actually set.

enter image description here

2 Answers

DTM does not currently offer a way to delay the s.t (or s.tl) trigger in Event Based Rules (EBR), so you will have to write your own javascript that ultimately makes the s.t call.

Since your screenshot shows the Adobe Analytics (AA) section in your EBR, it sounds like you have AA setup as a Tool in DTM. DTM lets you reference the AA s object within the custom code section of the AA section of a tool, but it doesn't have an official way to get a reference of AA s object outside of that scope.

So in order to achieve this, you have to put the s object into the global (window) scope in the Tool config. You can do this by adding a line in the custom code box of the AA Tool config

window.s = s;

(or if you changed the namespace to something else in the tool config, use that instead).

Next, a note about using this - I noticed in your screenshot for Page Name you have %this.getAttribute(data-search-pagename)%. Because you want to delay the s.t call, whatever you are doing (e.g. a setTimeout, popping it inside some ajax callback function, etc.) will almost certainly take you out of the scope where this properly references the element the EBR is based off of, so you will no longer be able to use this to populate the page name.

To get around this, go to the Conditions section of the EBR. Under Rule Conditions > Criteria, choose Data : Custom. In the Custom code box, you can add the following:

_satellite.setVar('data_search_pagename',this.getAttribute('data-search-pagename'));
return true;

The above will push the data-search-pagename attribute value to a Data Element named 'data_search_pagename' (or name it whatever you want, according to your conventions). The return true; part will always make this condition true, so that it is "invisible" to your rule and not actually affect whether or not the rule should trigger.

Finally, in the EBR, you will not use the AA tool section (choose the disabled option in that section). Instead, you will need to create and add your code in the Javascript / Third Party Tags section of the EBR. You will need to set whatever AA vars you had in the AA section as regular javascript variables, and for the Data Element %data_element% syntax, instead use the _satellite.getVar('data_element') javascript syntax .

I'm not sure what kind of delay you are looking to do, but here's a 100ms delay as an example (based on what is shown in your screenshot):

window.setTimeout(function() {
    var s = window.s;
    s.pageName = _satellite.getVar('data_search_pagename');
    s.channel = _satellite.getVar('util_channel');
    s.t();
},100);

If you have lots of these types of events on your site where the page view call needs to be more controlled, I would recommend using a direct call rule and aborting the initial AA PV call. In fact, it is common to create a "global page load" rule for single page applications (SPA) or for when you are waiting for ajax to return search results - for example

Here's a jQuery example of using a direct call rule within a search results page rule that will fire after ajax has completed and returned:

Javascript: jQuery - wait for callback and call DC rule

/* Ajax Detection on SRP */ 
    $(document).ajaxComplete(function( event, xhr, settings ) {
    _satellite.track('my_pageView_rule_here')

})

Hope this helps.

Related