Advanced Multitrack options
  • 08 May 2020
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

Advanced Multitrack options

  • Dark
    Light
  • PDF

Article summary

Inline transforms, callbacks, inline finish, and delayTime are advanced multitrack options.

Inline Transforms:

Transforms allow you to modify the Tag and/or Multitrack object just before the beacon request is created. Transforms come in two flavors: inline and global. The global transform applies to all Multitrack calls, whereas the inline version only applies to the a single Multitrack call.

Inline Transform example:

Webtrends.multiTrack({
        argsa: ["DCS.dcsuri", "/home/help"],
        transform: function (dcsObject, mtrackObject) {
                dcsObject.i18n = false;
                mtrackObject.argsa.push(
                        ["WT.ti", $('myTitleText').value()]
                );
        }
});

Global transforms are bound using Webtrends.addTransform.

Inline Finish:

Finish functions are transform functions that are called after the beacon request has been sent. This is a place were you can undo changes made in the transform function. For example in the above example, you may have wanted to turn the i18n flag back on after the multiTrack call finished.

Inline Finish function:

Webtrends.multiTrack({
        argsa: ["DCS.dcsuri", "/home/help"],
        transform: function (dcsObject, mtrackObject) {
                dcsObject.i18n = false;
                mtrackObject.argsa.push(
                        ["WT.ti", $('myTitleText').value()]
                );
        },
        finish: function (dcsObject, mtrackObject) {
                dcsObject.i18n = true;
        }
});

Like Transforms you can also add global finish event listeners, by using Webtrends.bindevent.

Callbacks:

Callback functions are called after the data collection server has successfully recorded the event or when a timeout event happens waiting for the collection server to respond. The timeout timer uses Webtrends.dcsdelay as the timeout time. Please note that the callback will be fired asynchronous to the Multitrack call, since loading images are non-blocking.

Webtrends.multiTrack({
        argsa: ["DCS.dcsuri", "/home/help"],
        callback: function (a) {
                //let's guarantee that the event was collected before moving to a new page.
                window.location = "http://webtrends.com/help";
        }
});

delayTime:

The delayTime flag (in milliseconds) tells the multiTrack call how long to wait after creating the beacon request before returning control back to the caller. This delay is done using a spinlock, which delays the event-dispatcher thread while the thread which will download the dcs.gif (aka the beacon) warms up.

This solves a problem with newer versions of Firefox and Chrome were image requests are canceled while changing document locations. By stalling the dispatcher thread just a few milliseconds, it gives the network thread time to warm up and start the download process.

Webtrends.multiTrack({
        argsa: ["DCS.dcsuri", "/home/help"],
        delayTime: 20 //delay returning to the caller by 20 milliseconds
});

Was this article helpful?