Accepted Solutions (1)

Accepted Solutions (1)

andrew_r-GrfLbX

27-07-2017

Do you mean the callback functions in AppMeasurement from v1.8.0 onwards?

Documentation on it is pretty light but it's straightforward to use. If you have a specific question ask away.

Added the following pre- and post-tracking call hooks.

  • s.registerPreTrackCallback
  • s.registerPostTrackCallback

These functions take as parameters: the callback (a function), and the parameters to that function. For example:

s.registerPreTrackCallback(function(requestUrl,a,b,c) {

console.log("pre track callback");

console.dir(requestUrl); // Request URL

console.dir(a); // param1

console.dir(b); // param2

console.dir(c); // param3 }, "param1", "param2", "param3");

The callback is invoked with the requestUrl and any parameters passed in when the callback is registered. This occurs either before or after the tracking call, depending on which method is used to register the callback. The order in which these callbacks are called is not guaranteed. Callbacks registered in the pre function are invoked after the final tracking URL is created. The post callbacks are called upon a successful tracking call (if the tracking call fails, these functions are not called). Any callback registered with registerPreTrackCallback do not affect the tracking call. Also, calling any of the tracking methods in any registered callback is not recommended and could cause an infinite loop.

Answers (5)

Answers (5)

ericmatisoff

Employee

31-07-2017

Hey michael.won@jet.com​,

I've been putting the following code into DTM via the "Customize Page Code" accordion in the AA Tool. Be sure to keep it OUTSIDE of doPlugins or you'll have a bit of a mess on your hands:

Hope that helps!

MichaelWon

MVP

27-07-2017

Hi Andrew,

Thanks for sharing, and I was able to find this. Can you please help with the following:

1. If I want just want to set s.clearVars(); after any server call, what does the code look like?

2. Once, we have the code where does it go?

I found/read the same article as you. Because I am a JS novice, I am unclear how and where to fire the Callback.

Thanks,

Michael