Overview & Basic Info

Basically, the tracking code looks like the following example. Only in the upper part are changes needed, based on what information you want to send to the API.

In every call to the API you need to specify your website ID. You find this ID in the Dashboard on the settings-page of the corresponding Website.

function ttio()
{
    var ttio = new ttio_int();
    ttio.data.websiteid = [WEBSITEID];

    /* define some more variables here */

    ttio.track("pageview");
}

var ttio_cdn = "https://api.tracktech.io/tracker.js";
if(typeof(ttio_int) != "function")
{
    var a = document.createElement("script");
    a.type = "text/javascript", a.readyState ? a.onreadystatechange = function() {
        ("loaded" == a.readyState || "complete" == a.readyState)
    } : a.onload = function() {
        ttio()
    }, a.src = ttio_cdn, document.getElementsByTagName("head")[0].appendChild(a)
}
else { ttio(); }

Pageview-Tracking

The basic pageview tracking code is the following. While the lower part is static and always the same, you have to change to upper part – the function ttio(). The basic is always:

function ttio()
{
    var ttio = new ttio_int(); // initiate new tracking object
    ttio.data.websiteid = [WEBSITEID]; // your websiteid

    /* define some more variables here */

    ttio.track("pageview"); // type of request. "pageview" or "conversion"
}

enhanced pageview tracking

You can add some more data to every pageview. To add more data, simply add the corresponding variable from the following table. The additional variables must add before this line: ttio.track(„pageview“);.

Variable / Code accepted values Description
this.data.userid string, 36 characters (A-Z, a-z, 0-9) Identifies a specific user. Use it, when the user is logged into your website. Use something like a UserID or eMail, what exactly identifies a user. You can hash this value.
this.data.pagetype ‚homepage‘, ‚category‘, ‚product‘, ‚cart‘, ‚checkout‘, ’success‘, ‚content‘, ’search‘ Defines the type of the current page.
this.data.searchterm string, 200 characters The keyword the user is searching for, while using you internal serach. In this case the ‚pagetype‘ should also be ’search‘.
this.data.basket.value decimal, max value is 99999.99 The value of the current basket without VAT and shipping.
this.data.basket.count decimal, max value is 99999 The number of products in the current basket.

Conversion-Tracking

To track a conversion you add some conversion data and change the tracking type to „conversion“ like this:

function ttio()
{
    var ttio = new ttio_int();
    ttio.data.websiteid = [WEBSITEID];

    ttio.data.conversion.number = [ORDER NUMBER];
    ttio.data.conversion.value = [ORDER REVENUE];
    ttio.data.conversion.currency = [ORDER CURRENCY];

    ttio.track("conversion");
}

If you track a conversion, you do not have to track a pageview as well. The conversion tracking happens typically on the success-page.

enhanced conversion tracking

Code accepted values Description
this.data.conversion.number string, 200 characters (A-Z, a-z, 0-9) An unique id from your system to identify this order.
this.data.conversion.value decimal, max value is 99999.99 The value of the order without VAT and shipping.
this.data.conversion.count decimal, max value is 99999 The number of products in this order.
this.data.conversion.currency currency in ISO 4217 (read more) The currency of the order like EUR, USD, etc.
this.data.conversion.guestuser bool (1 or 0) 0 = User has an account; 1 = guestuser / guestcheckout
this.data.conversion.vouchercode string, 200 characters (A-Z, a-z, 0-9) Vouchercode used in this oder
this.data.conversion.vouchername string, 200 characters (A-Z, a-z, 0-9) Vouchername used in this oder
this.data.conversion.payment string, 200 characters (A-Z, a-z, 0-9) Paymentmethod used in this oder

FAQ

How does the tracker work integrated in a single page application?

The tracking code is developed to work fast and without unnecessary ressources also in single page applications. If the tracking script is loaded once, it will use the old ressources again.

My tracking code is not working. What can I do?

If the tracking code is not working (no data in dashboard or errors in the JS console), you can do the following: