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.