Javascript - when a tracking call has completed? | Community
Skip to main content
pwolly-cr
Level 2
September 22, 2020
Solved

Javascript - when a tracking call has completed?

  • September 22, 2020
  • 1 reply
  • 2224 views
Hello!
Does anyone know if there is a reliable way in javascript to detect whether the adobe analytics page tracking call (s.t()) has completed?  Currently, we are attempting to test for this via the below javascript (that tries to determine the state of the image beacon added to the page):
 
var pageViewComplete = function(){
    var pageViewPixel = window.s_i_scglobal;
    if (pageViewPixel && pageViewPixel.src && (pageViewPixel.src.indexOf('/b/ss/') >= 0) && pageViewPixel.complete){
      return true;
    }
    return false;
  };
 
We have noted that on occasion, the page view is recorded via an AJAX post to our adobe server vs the inclusion of the <img> tag, so the above code doesn't not always work.
 
Is there any Adobe supported way to test for this?
 
Thanks!
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Brian_Johnson_

@pwolly-cr  - Have you considered s.registerPostTrackCallback?

https://docs.adobe.com/content/help/en/analytics/implementation/vars/functions/registerposttrackcallback.html

1 reply

Brian_Johnson_
Brian_Johnson_Accepted solution
Level 8
September 22, 2020
September 24, 2020
@yuhuisg The problem we are trying to solve is that the page calls on our site depend on an ajax call to complete before firing. The new platform we are integrating with requires a link tracker call to record its additional metrics, and this happens asynchronously (we can't control the timing of it - the trigger to it is nested in a callback from a script they load async). At certain times, the s.tl() call for the vendor metrics recording can precede the page tracking call (which corrupts the data in our direct traffic report). @brian_johnson_ In the idea you proposed, wouldn't registerPostTrackCallback also fire after the call to s.tl() in which case if that happens to go first, we'd still have this problem?