5

Omniture's basic page tracking function, s.t(), was not crafted for AJAX implementation. Unlike the onclick s.tl() function which has some gating instructions with s.linkTrackVars and s.linkTrackEvents, the s.t() function just perpetuates every cached property through to the next call and beyond.

I used to be able to use a ClearVars function to empty out all of the s object's attributes, but now that I am using AppMeasurement and letting DTM manage my implementation with the most updated version of that library—which I want to keep doing—I can't call the s object. I get the same "ReferenceError: s is not defined" that another person asked about here!.

I tried following Crayon Violent's instructions within that post, but I can't seem to find where DTM is stashing the cached values in between Adobe calls. This code:

window.s = new AppMeasurement();    

lets me change/clear the attributes of s, but it's not the s I'm looking for. When I call the next AJAX s.t() function, all of the cached values are still there.

Community
  • 1
  • 1

1 Answers1

7

In my experience working with DTM and AA, there has been no end to bugs and caveats and workarounds with DTM's "native integration" of AA. This is why I have more or less decided that the best thing I can do is to either manage the lib myself or else treat AA as a 3rd party script (100% implement it through rules, just ignore that it's available as a tool).

As mentioned in my answer you linked, that line of code only works to expose the AA object in the window namespace if you are managing the library yourself. When you configure DTM to manage the library, it will instantiate AA object itself, and it will be buried within its own code (Honestly, I don't know why DTM did this, considering AA puts a number of other variables in the global namespace that DTM does nothing about).

AFAIK there is no documented way to reference it, but one thing I have found that seems to work for me - which as a disclaimer to cover my own arse I do NOT officially endorse: use at your own risk - is to use the following to get a reference of it:

var s = _satellite.getToolsByType('sc')[0].getS();

This uses getToolsByType method to get an array of the SiteCatalyst (Adobe Analytics) objects setup as tools in DTM. It does this by looping through _satellite.tools and comparing _satellite.tools[n].settings.engine to what you passed to getToolsByType.

Then I use [0] to get the first one in the array, under the assumption that there's only one configured (most people only do one). Then the getS() object pulls together the s object based on the settings in DTM. So from there, you can do things with it, including making use of s.clearVars()

CrayonViolent
  • 32,111
  • 5
  • 56
  • 79
  • You're the bomb Josh! If I had any reputation points on this site I would vote up your answer! :) But from your other posts I suspected you'd have figured out a sneaky way to crack the code. As it was I was having to make an additional s.tl() call just to run my clearVars function, since that's the only place I could seem to access the AA object. Nonsense! You probably don't need it, but here's a similar loop that I built to clear cached data layer variables from DTM via the Data Element list. I was pretty chuffed with myself for writing it--I'd love to hear of any improvements you'd advise. – Craig Scribner Dec 05 '14 at 00:24
  • 1
    //this function finds all of the existing Javascript objects in the current system //and resets them to blank one by one. for(i=0;i – Craig Scribner Dec 05 '14 at 00:28
  • @Crayon, wondering where to put the above code in DTM? My goal is to clearVars prior to every call? as I have one page ajax app. Currently I am using DTM hosted option but I am using my own S-Code -- wondering if I should add it there as it will be called globally. Thanks. – wailer Jan 21 '15 at 03:28
  • @wailer since you made a [separate question here](http://stackoverflow.com/questions/28048759/when-and-how-to-use-s-clearvars-in-omniture), and my thoughts are a bit longer than a comment will afford, I have posted there instead of here. – CrayonViolent Jan 21 '15 at 14:06
  • OK I don't normally give "+1" type comments but this answer is just sick. Props dude, I was amazed at this (and it worked for me.) – JD Smith Jul 05 '16 at 22:14