Question

I'm looking to develop a Omniture "trouble" tag that will fire within Google Tag Manager. This tag should check to see whether the Omniture s.code on-page has fired a pageview. If it hasn't, send an Event to our GA account.

Ideally, it'd look like this (pseudocode follows):

<script>
window.onload=function(){if(OmniturePageViewHasFired == false){
ga('send','event','SCodeMissing','Page',window.location.href);
}}
</script>

Just checking to see whether the s.code is on page at all is a much easier task, but won't be as useful since it's possible for the code to be on page and not have fired. Any ideas? Also note that I do NOT have access to the s.code itself, so I can't set a variable with it that's then picked up by this script.

Was it helpful?

Solution

This is how I'd do it, based on how Adobe's DigitalPulse Debugger looks for it:

function OmniturePageViewHasFired() {
  var i=document.images;
  for (var c=0,l=i.length;c<l;c++) {
    if ( (i[c].src.indexOf('/b/ss/')>=0)
         && (!i[c].src.match(/[&?]pe=/))
    ) return true;
  }
  for (var o in window) {
    if ( (o.substring(0,4)=='s_i_')
         && (window[o].src)
         && (window[o].src.indexOf('/b/ss/')>=0)
         && (!window[o].src.match(/[&?]pe=/))
    ) return true;
  }
  return false;
}

//example:
if (OmniturePageViewHasFired() == false){
  // no omn request detected
} else {
  // found at least 1
}

Note 1: This will only return true if a page view (s.t) request is made. It will not return true for click requests (s.tl). If you want it to return true for any request, then remove the last &&.. in the 2 conditions.

Note 2: Officially Adobe thinks it is good enough to just look for /b/ss/ in the src. Admittedly, in all my years of QA'ing Adobe Analytics (btw that's what it's called now, not Omniture), I've only seen a false positive from this like one or two times.

If this worries you, you can make the condition more specific by evaluating the domain of the src for your implementation. This is unique to your implementation, which is why Adobe doesn't look for something more specific. Just look at a request on your page to get it.

OTHER TIPS

You can add your own code to track whether or not Omniture has fired.

There is a plugin feature, and Omniture uses to fire plugins and other code on a tracking event. This function is fired everytime a pageview or on-click event, or any other type of Omniture event is fired.

You'll want to make sure that this is not used elsewhere to enable Omniture plugins, if it is, you'll have to be able to update that code. Basically you could do something like the following, as long as you make sure that the following bit of code loads and exectues (after) the s_code.js file loads and executes:

var om_fired = false;

s.usePlugins=true;
function s_doPlugins(s) {
     om_fired = true;
}
s.doPlugins=s_doPlugins;

Then in your google code just check to see if om_fired is true/false

Another way to do it (adding it here since it was too long for a comment).

Before s.code loads, add some script that reads the cookies that are set by Omniture, I don't remember the exact cookie names, but multiple cookies are set. Your code that reads the cookie will need to be in the header so it fires as the page loads( and before site cat tracking code), and before page load completes. Read the omniture cookie, and check the values, there is one in there for Time Since Last hit, I believe the cookie variable is something like s.tlh. Store that value away, then after page load fire another call that reads the cookie again and check to see if the tlh value changed. If it did then your tracking event occured. If it did not change, then your event did not fire. Your challenge will be to make sure the code fires in the right order, i.e. 1. Read cookie/store value, 2. Site Cat Fires, 3. Read cookie again and compare w/ cookie in #1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top