Skip to main content

Setting up the tracking script

This article will show you how to configure and implement the Voyado Engage tracking script.

What is a tracking script?

A tracking script allows you to gather behavioral data such as cart changes and product views from website visitors. It consists of a small snippet of code, usually as JavaScript, placed in the HTML source code of a website. The tracking script is required for using features like abandoned cart and products of interest. The tracking script should not be confused with tracking parameters attached to the URL.

Once the script is implemented it will generate a unique client ID and store it in a first-party cookie named _va. All web activity on that browser is then linked to that client ID via the cookie. When that user clicks on a link in an email from Engage, the tracking script reads the contact ID from the URL (vtid) and stores it in a cookie named _vaI. With this method, web activities can be connected to a specific contact in Engage.

Caution

Note that the string "_vaI" is _va followed by an uppercase letter I (as in Ingemar) which can be difficult to make out in some fonts (like this one).

Configuring the tracking script

This is the Voyado tracking script:

<script>
    (function (i, s, o, g, r, a, m) {
        i['VoyadoAnalyticsObject'] = r;
        i[r] = i[r] || function () { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date();
        a = s.createElement(o), m = s.getElementsByTagName(o)[0];
        a.async = 1;
        a.src = g;
        m.parentNode.insertBefore(a, m)
    })(window, document, 'script', '[SCRIPT-PATH]', 'va');
    va("setTenant", "[TENANT-ID]");
</script>

Two things need to be changed here before you can use it, [SCRIPT-PATH] and [TENANT-ID].

[SCRIPT-PATH]

This is the path to the JavaScript analytics package. There are just two options you can use, depending on if you are running in the staging or production environment.

For the production environment, change [SCRIPT-PATH] to:

https://assets.voyado.com/jsfiles/analytics_0.1.7.min.js

And for the staging environment [SCRIPT-PATH] will be:

https://assets.voyado.com/jsfiles/analytics_0.1.7.staging.min.js

Note that analytics_0.1.7 refers to the latest version but can be changed to whatever version you need.

[TENANT-ID]

This string is your unique client (tenant) ID and is the same in production and staging. It is usually the subdomain name in *.voyado.com. For instance, the [TENANT-ID] for supershop.voyado.com would just be "supershop".

Contact your Voyado Engage team if you are unsure about this.

Once you know these two values, you can put them in to configure your tracking script.

Here's an example of how it looks when it is configured.

<script>
    (function (i, s, o, g, r, a, m) {
        i['VoyadoAnalyticsObject'] = r;
        i[r] = i[r] || function () { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date();
        a = s.createElement(o), m = s.getElementsByTagName(o)[0];
        a.async = 1;
        a.src = g;
        m.parentNode.insertBefore(a, m)
    })(window, document, 'script', 'https://assets.voyado.com/jsfiles/analytics_0.1.7.min.js', 'va');
    va("setTenant", "supershop");
</script>

Implementing the tracking script

The tracking script can now be placed as it is (implemented in code) on your website, or implemented through a tag manager such as Google Tag Manager (GTM).

A. Implemented in code

Copy your configured code snippet and paste it right after the <head> tag in the HTML page of each page on your website. It's vital, on every page it's used, that the script is initiated and always running, so that it can catch all relevant interactions like cart changes and productviews (through the script's cart and productview methods).

B. Implemented through Google Tag Manager

Follow the steps below:

  1. Log into your Tag Manager.

  2. Select "New Tag".

  3. Name your Tag something easily recognizable.

  4. Open “Tag configuration” and select “Custom HTML” as tag type.

  5. Copy and paste your configured tracking script into the box.

  6. Open ”Triggers” and select the trigger “All pages” (recommended).

  7. Save your Tag.

  8. Publish the new version of your Tag container.

Important

The tracking script can identify which user has arrived via an email link and is therefore required on all pages on your site, including non-product and other landing pages. Make sure the script is implemented on all pages or you risk the user not being identified.

Server-side cookie support

To increase the identification rate for Safari browsers, cookies can be created server-side. The latest script version (0.1.7) supports this. See this article to read more and see how to adjust your implementation.