The registerPreTrackCallback
variable allows your organization to hook a JavaScript function after an image request URL is compiled but before it is sent. You can use this variable to send data collected by AppMeasurement to a partner or in-house infrastructure.
Each time you call the registerPreTrackCallback
variable, you hook that function to run every time an image request URL is compiled. Avoid registering the same function multiple times in the same page load.
The timing and order of functions fired between registerPreTrackCallback
and registerPostTrackCallback
are not guaranteed. Avoid dependencies between these two functions.
The Web SDK cannot hook a function after data is compiled but before it is sent to Adobe. However, you can use onBeforeEventSend
to register a function to execute just before data is sent.
The Web SDK cannot hook a function after data is compiled but before it is sent to Adobe. However, you can use onBeforeEventSend
to register a function to execute just before data is sent, similar to doPlugins
. See Modifying events globally in the Web SDK documentation for more information.
// Set the trackingCode XDM field to "New value"
alloy("configure", {
"onBeforeEventSend": function(content) {
content.xdm.marketing.trackingCode = "New value";
}
})
There is not a dedicated field in the Adobe Analytics extension to use this variable. Use the custom code editor, following AppMeasurement syntax.
The s.registerPreTrackCallback
is a function that takes a function as its only argument. The nested function runs just before an image request is sent.
s.registerPreTrackCallback(function(){/* Desired code */});
If you want to use the image request URL in your code, reference the requestUrl
string argument within the nested function. You can parse the requestUrl
variable for your desired use; adjusting this variable does not impact data collection.
s.registerPreTrackCallback(function(requestUrl){
console.log(requestUrl); // Outputs the full image request URL
});
You can include additional arguments in the s.registerPreTrackCallback
function, which can be used in the nested function:
s.registerPreTrackCallback(function(requestUrl,a,b,c) {
console.log(requestUrl); // Full image request URL
console.log(a); // param1
console.log(b); // param2
console.log(c); // param3
}, "param1", "param2", "param3");
Setting page variables or altering the requestUrl
string within this function do not impact the image request sent shortly after this function call. Use the doPlugins()
variable instead.