Using the Push Function

Prev Next

1 Overview

The Smart Pixel is loaded asynchronously to avoid blocking the page load. Because of this, any tracking method (such as init.set() or track()) must be executed only after the script has fully loaded.

To ensure this, Mapp Intelligence uses the wtSmart.push() function. It ensures that all tracking-related code runs only when the Smart Pixel is ready.

We strongly recommend using this function for all tracking calls. If the Smart Pixel script isn’t loaded — for example, due to browser extensions or network issues — calling tracking functions directly may trigger JavaScript errors and disrupt parts of your website.

Using wtSmart.push() not only ensures correct tracking execution — it also prevents potential JavaScript errors that could affect your website’s stability.


2 Syntax

/**
 * @param {function(wtSmart)} fn
 */
wtSmart.push(fn);

Example

window.wtSmart = window.wtSmart || [];
window.wtSmart.push(function(wtSmart) {
    // set initial tracking config
    wtSmart.init.set({
        trackId: '111111111111111',
        trackDomain: 'q3.webtrekk.net'
    });
    
    // set page data
    wtSmart.page.data.set('en.index.home');
    
    // send tracking data and remove data after request
    wtSmart.track();
});