Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
361 views
in Technique[技术] by (71.8m points)

adobe analytics - When and how to use s.clearVars in Omniture?

I am trying to understand where in DTM can I use s.clearVars? do I place it under "custom page code" under Global config or under Rules "custom page code"?

Also what are the downside to clear all the variables? am I also going to clear built-in Omniture variables (e.g. Campaign ID)? Or what is the best way to clear all custom (evar, props and events - things I set) in DTM?

My Ajax application seems to be caching data from call to call. I am experiencing the following problem.

http://trackingfirst.com/omniture-ajax-cache-issues/

Keen to understand s.clearVars how to use it in DTM. Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm not sure I can give a definitive answer about best way to go about it without being able to fully evaluate your DTM setup, but one thing you could try:

In the rule where you are ultimately making your s.t or s.tl calls, do the following:

In the Conditions section, under Rule condition, choose Data > Custom and click the "Add Criteria" button.

Then in code box, put in:

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

Update: You commented the following:

Thank you for your answer. Unfortunately my rules are all direct call rules and there seems to be no "condition" option in DTM. I have added the above code under - "custom page code" - analytics tool settings - but interestingly "custom page code" don't get call for direct call rules. I am going to try running it via "javascript/3rd party tags" see what happens. Other ideas I could try? thanks

You are right, Direct Call rules only have one condition and that is the string passed in the _satellite.track('string') call. Honestly, I have no idea why Adobe does this. Maybe one day Adobe will expand it to allow you to setup other conditions for direct call rules, and basically just have that "string" condition relabeled to be the direct call rule identifier to specify which one to invoke. Basically, they should just treat it like the page load and event based rules, except you just invoke it with that "string". Incidentally, that's sort of how rules are already invoked internally, within the core code (even the page load and event based rules) so it wouldn't be that much of a stretch for Adobe to expand Direct Call rules.

Also, you are right, adding the code to the "custom page code" section in the tool settings won't work either. That chunk of code only gets executed on initial load of the DTM library. Speaking of setting things in that custom page code section.. there are other "bugs" you should be aware of, if you are setting other Omniture vars there. Long story short is DTM doesn't just create an s object on first load and then reference it later during rules; it creates a whole new s object when a rule is triggered. So, if you set anything within those tool config custom code boxes (e.g. manually setting linkTrackVars or more commonly, making use of s_doPlugins which is also conspicuously missing from being baked into DTM...) they will NOT get preserved for direct rule calls! (But, it does preserve it from direct call to direct call. I know.. confusing and inconsistent, right?)

So this leads up to a solution for you.. basically, you need to disable letting DTM trigger the s.t or s.tl call. Just keep the radio button in Adobe Anlytics section set to "disabled" and then set everything you need to set manually, within a code box in the Javascript / Third Party Tags section. Within there, you can put that code, then set any additional Omniture variables you need to set. If you need to reference Data Elements, you can use _satellite.getVar('element_name') to get them, instead of the %element_name% placeholder you'd use in the Adobe Analytics section. Then, end it with the s.t() or s.tl() call yourself. In other words.. treat it as a normal Omniture implementation, where the code just happens to be hosted in DTM, instead of making use of whatever DTM has built in.

Update: AppMeasurement 1.8.0

AppMeasurement Release Notes (scroll down to JavaScript 1.8.0)

Adobe introduced two events you can register callback functions to:

s.registerPreTrackCallback
s.registerPostTrackCallback

With this, you can register a callback function that triggers s.clearVars()

Example

s.registerPreTrackCallback(function() {
  s.clearVars();
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...