I want to to check if the s.t() or page load has already been called on a site. I control when it gets called, but I want a very generic way to ask if it has already been called. The main purpose is to either call s.t() or s.tl() depending on what has previously happened.
Asked
Active
Viewed 940 times
5 Answers
4
This will return true if the SiteCatalyst code has fired.
(function(){for(w_m in window)if(w_m.substring(0,4)=='s_i_'&&window[w_m].src)if(window[w_m].src.indexOf('/b/ss/')>=0)return!0;})()

VaBeachKevin
- 264
- 1
- 1
1
Unfortunately I do not know when this was introduced to AppMeasurement and I did not find any documentation about it but I accidentially found the following two callback functions that we use successfully to identify the moment shortly before and after the tracking request.
s.registerPreTrackCallback(function() {
console.log('Pre-Track');
});
s.registerPostTrackCallback(function() {
console.log('Post-Track');
});

Shoe
- 31
- 3
-
Those appear to still be useful today. Search the web for "Adobe analytics registerPreTrackCallback" and you will see the latest documentation for it. – King Holly Dec 04 '20 at 01:25
0
This answer gives the concept behind it- before firing either function, check if the other was already fired. For example:
s.pageName="page";
s.eVar1="value";
if(!linkFired) {
var pageFired=true;
s.t();
}
if(!pageFired) {
var linkFired=true;
s.tl(this,'o','custom link');
}
0
I'm not sure this will actually give you any answers but you could also overwrite the s.t function with something like:
s.AltSt = s.t;
s.t = function (vo) {
s.AltSt(vo);
console.log("Do your own stuff!");
}
Haven't 100% tested this but on first observation this should work..

Cohen
- 640
- 1
- 6
- 6
0
you could wait to see if s is called
setTimeout(function checkIfsLoad() {
if (typeof s == 'object') {
doYourStuff();
} else {
setTimeout(checkIfsLoad,150);
}
}, 150);