- Identification and cookies
- Abandoned carts
- Product views
Introductory concepts
Here are a list of the basic concepts in this area.1 - Identification and cookies
The foundation of web activity tracking is identification and cookies. A contact can be identified through the script in three ways:- An email link (sent from Engage) that takes them to the website.
- Being identified by the website by, for example, signing in, in which case the method setContactId() is called.
- Being identified by an exiting _vaI cookie, previously set by the Voyado script.
2 - Abandoned cart
The tracking script enables abandoned cart functionality. By registering every state of a user’s cart, Engage is able to receive information about cart abandonment and use this to trigger automations. How to get started:- Configure a product feed, read more here.
- Implement the tracking script, read more here. [LINK]
- Track cart changes, read more here. [LINK]
Learn more about abandoned cart from a user's perspective.
3 - Abandoned browse
The tracking script enables abandoned browse functionality, in the same way as abandoned cart. The site sends product view and cart events to Engage through the tracking script (or the API if the user has been identified). Using this Engage can detect when a session is abandoned and nothing has been added to the cart and then trigger an automation. How to get started:- First implement everything for Abandoned cart (see above).
- Track product views, including locale. Read more here. [LINK]
Learn more about abandoned cart from a user's perspective.
4 - Products of interest
By tracking which products a user interacts with, Engage can calculate a list of products of interest. This can then be used in, for example, segmentations. This data will also be a part of the algorithm that calculates Engage’s product recommendations.- Configure a product feed, read more here.
- Implement the tracking script (read more here) [LINK].
- Track product views, (read more here). [LINK]
5 - The sessionId
ThesessionId value is unique for every session. When using the tracking script, this is included automatically in the data sent. However, if you are using the API to handle web activity tracking, the sessionId needs to be manually added to the payload that you send.
Engage will check if “cart” and “productView” events are using the same sessionId. If they are, then only the Abandoned Cart automation in Engage will be triggered. The Abandoned Browse automation will only get triggered if there are no cart events registered during the session that has that specific sessionId.
Setting up the 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 any 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 (vtid) from the URL and stores it in a cookie named _vaI. With this method, web activities can be connected to a specific contact in Engage.
Configuring the tracking script
This is the Voyado tracking script:[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 -
For the staging environment [SCRIPT-PATH] will be:
https://assets.voyado.com/jsfiles/analytics_0.1.7.staging.min.js
[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.Example of use
Once you know [SCRIPT-PATH] and [TENANT-ID], you can put them in to configure your tracking script. Here’s an example of how it looks when it is configured.Implementing the tracking script
The tracking script can now be placed as it is (implemented in code) on your website, or it can be 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.B. Implemented via Google Tag Manager
Follow these step:- Log into your Tag Manager.
- Select “New Tag”.
- Name your Tag something easily recognizable.
- Open “Tag configuration” and select “Custom HTML” as tag type.
- Copy and paste your configured tracking script into the box.
- Open ”Triggers” and select the trigger “All pages” (recommended).
- Save your Tag.
- Publish the new version of your Tag container.
Identification and cookies
This section will help you understand:- The setContactId() function
- Identification through clicking a link in an email
- Identification on-site
- Best practices concerning cookies and identification
- Important steps to ensure during implementation
Identification
Identification means linking a user to a contact ID in Engage. When a user is identified, it’s then possible to build an understanding of their behavior on the site and offer a personalized experience and more relevant communication. Common situations when a visitor is identified are:- A contact registers as a newsletter subscriber
- A contact registers for a loyalty program
- A contact logs in
- A contact completes a purchase
- A contact uses a soft identification [LINK]
Using setContactId() on identified users
As soon as a visitor is identified by the site (see the common cases listed above) thesetContactId() method should be invoked.
Keep in mind the visitor might already be identified (such as by an email link click), and invoking this method incorrectly might clear the existing identification. The function setContactId() will not generate a HTTP request to the Collect endpoint.
Identified and non-identified tracking events
From when a contact is identified, all upcoming tracking events from the same browser are linked to them. This applies until the first-party cookie disappears or changes (for example, when another user logs into the site from the same browser). Voyado recommends that the e-com always includes thecontactId in all tracking events such as cart() and productview().
Regardless of whether the contact is identified or not, all tracking events are always linked to the browser via a first-party cookie. That means anonymous tracking events can be linked to a contact ID afterwards, and the e-com site should not limit tracking events such as cart() and productview() to only identified or logged-in users.
The relevant cookies
| Name | Content | Example | Life span* |
|---|---|---|---|
| _va | Client ID. Generated by the script and links all events to a specific contact. | VA671.1135834162 | 1 year |
| _vaI | Contact ID (guid/shortguid). If the contact is identified in Engage this links events to them. | a8tPsy8eqUm-yKoeAMPv7Q | 1 year |
Support for server-side cookies
The cookie _vaI (which stores thecontactId) is created client-side by the script. With Apple ITP (Intelligent Tracking Prevention) all client-side cookies (and LocalStorage) have a capped lifetime of 7 days in Safari. Which means that when an identified visitor doesn’t revisit the site within 7 days, the cookie will expire and the script won’t be able to identify the visitor using the _vaI cookie.
The cookie lifetime cap applies only to cookies created client-side (with Safari) and doesn’t affect server-side created cookies. The tracking script now supports copying the value from a cookie _vaI_server created server-side as a fallback to recreate the client-side cookie _vaI.
The cookie _vaI will be recreated, if needed, in this specific order:
- The site invokes setContactId() or includes contactId in an event
- The URL param vtid exists
- The LocalStorage key vtid exists
- The cookie _vaI_server exists

Tracking cart changes
Cart changes can be tracked either with the Voyado Engage tracking script or the tracking API. Engage can trigger abandoned cart communication to be sent to identified contacts. To enable this, Engage need to know:- Every update of every unique shopping cart
- The
contactIdof the visitor
- cart(): Used for registering visitor actions related to any cart modification
- emptyCart(): Used for pruning the cart of all items, usually when indicating a purchase or logout by the e-com visitor
Data flow
This is how the flow looks:- The site submits shopping cart changes, either via the tracking script implemented on the e-com site or through the tracking API.
- Carts containing products that haven’t been accessed for at least 30 minutes are considered abandoned. If the cart is connected to a specific contact it will be sent to Engage. All other carts will be filtered out.
- Engage then triggers the relevant automation (based on language/locale).
Cart automation requirements
The following are required so that an abaondoned cart automation can be triggered:- The locale must match a product feed in Engage and the corresponding language must be set in an automation.
- The SKU/SKUs must match products in the product feed (commonly “g:id”). If a SKU doesn’t match the feed, that particular product will not be included in the email. If no SKUs match the products in the feed the automation won’t be triggered at all.
- No products in the cart have been purchased (meaning no transaction has been sent to Engage) since the cart was identified as abandoned (although this can be overruled when configuring the trigger).
Using the tracking script
Here is how to use the tracking script to track cart changes.A. The cart() method
Invoke this method every time the cart is changed (items added/removed or the quantity updated) regardless of if the user has been identified by the website or not. The cart() method will then generate a HTTP POST request to the Collect endpoint.B. The emptyCart() method
Invoke this method when the cart has been emptied, either manually by the user or when the checkout process has been completed. This method is equivalent to invoking cart() with no items. Itis important to invoke emptyCart() after each successful checkout to avoid faulty abandoned cart communications. The emptyCart() method will generate a HTTP POST request to the Collect endpoint.Using the tracking API
It’s possible to submit cart changes directly via the API instead of implementing the tracking script. If you choose this approach, it is important to identify all contacts that come to the e-com via links in emails (add “vtid” in “contactId”). The calls can be tested through your OpenAPI (Swagger) page.Read about the Engage API and your OpenAPI page
Important points when tracking cart changes
All behavioral data can be used to build understanding and insights. A shopping cart belonging to an anonymous user can still be linked to a contact after they are identified. If the user is identified / logged in, both the “cart()” script method and the Carts API can be used to track their behavior. For anonymous users, however, only the “cart()” script can be used. This is because the tracking API always requires the contactId. Cart updates: Call the “cart()” script method (for identified and anonymous users) or the Carts API (for identified users only) for all updates to the shopping cart, regardless of where on the site or at what stage the cart update takes place (product page, popup or checkout). Engage handles the shopping cart based on its latest change. It is therefore important that all changes generate a call to “cart()” or the Carts API and that the data corresponds to the shopping cart currently displayed on the website. cartRef: The “cartRef” value must be unique and must not be shared between different baskets or users. A “cartRef” of a specific shopping cart must not be changed, and all updates regarding a shopping cart must use the same “cartRef” value. Empty carts: Use “cartRef” for empty carts as well. Even empty carts need a cart reference. Locale: Call the “cart()” script method or Carts API with a “locale” value corresponding to the locale of your Product Feed in Engage. In order to enrich the products with article data, a Product Feed for that locale needs to be set up in Engage. An automation using that locale also needs to be active. Abandoned carts: All carts not emptied before the website visitor leaves, or makes a purchase, risk being marked as abandoned. If you have an abandoned cart automation active that will be triggered by those unemptied carts.Tracking product views
By tracking product views, Engage can:- Trigger abandoned browse automations
- Build audiences based on products of interest
- Get improved product recommendations
- Using the Voyado tracking script
- Using the tracking API
Features built on product views
The following features in Engage are enabled by the tracking of product views:- Abandoned browse
- Products of interest
- Product recommendations
Abandoned browse
- The site submits product views, which are part of a session, either via the tracking script implemented on the e-com site or through the tracking API.
- Sessions without activity for at least 30 minutes are considered abandoned. If the session doesn’t contain any cart event, and the product views are connected to a specific contact, it will be sent to Engage. All other sessions will be filtered out. A session can only be sent to Engage once.
- All product views sent to Engage are enriched with data from the product feed.
- Engage then triggers the relevant automation, based on the specific trigger configurations. If automations contain email activities those can include dynamic product data enriched from the product feed.
Read more about abandoned browse here.
Products of interest
- The site submits product views, which are part of a session, either via the tracking script implemented on the e-com site or through the tracking API.
- Engage, using the recency, frequency and other patterns of product views from the last 90 days, calculates up to 25 products which each contact is probably most interested in, based only on their onsite behaviour.
- These products are updated using a scheduled job and enriched by the article registry and can then be used in segmentation and as part of a scheduled selection in an automation.
Read more about products of interest here.
Product recommendations
If a contact has products of interest, these will be part of the data used to calculate personal recommendations in Engage. This means that their onsite behavior (Products of interest) will be combined with all historical purchase and return behavior to present a set of personalized recommendations that can be used in emails.Abandoned browse automation requirements
The following are required so that an abandoned browse automation can be triggered:- The locale must match a product feed in Engage. Events without a matching product feed will be filtered out.
- The SKUs must match products in the product feed (commonly “g:id”). If an SKU doesn’t match the feed, that particular product will not be included in the email. If no SKUs match the products in the feed, the automation won’t be triggered at all.
Using the tracking script
The tracking script to track product views works via the productview() method. Invoke this method every time a product is viewed, such as on a product page, whether the user has been identified by the website or not.Using the tracking API
It’s possible to submit product views directly via the API instead of implementing the tracking script. Keep in mind, if doing things this way, that a lot of functionality that exists out-of-the-box when using the script has to now be handled directly by the retailer. It’s important to identify contacts that enter the e-com from a link in a newsletter by reading the encrypted JSON that is sent in the link’s query string. This contains the information needed to identify the contact. Only identified product views can be registered via API (since the contactId is required). A product view is part of a session, identified by itssessionId, which is required for abandoned browse. This is handled automatically by the tracking script, but when using the API the sessionId has to be included in the payload in all calls.
Read more about the Engage REST API here.
Use cases
Here are some examples of web activity tracking:1 - Arriving via newsletter link
What happens: The user clicks a link to the e-com in an email newsletter that was sent out from Engage. The link is decorated with vtid (the contact ID). The user then views a specific product and invokes productview(). What you need to do:- Populate
categoryNamewith the current product category, for example:“categoryName”: ”Computer accessories \> Printers \> Toners”) - Populate
itemIdwith the current product SKU (e.g. “itemId”: “549852″) - Populate
localebased on the site’s current language/market (e.g. “locale“: “sv-SE“) - Populate
contactIdwith user’s contact ID from Engage (vtidis used as fallback)
2 - Arriving unidentified
What happens: An unidentified user browses into the e-com. They view a specific product, invoking productview(). What you need to do:- Populate
categoryNamewith the current product category, for example:“categoryName”: ”Computer accessories \> Printers \> Toners”) - Populate
itemIdwith the current product SKU (e.g. “itemId”: “549852″) - Populate
localebased on the site’s current language/market (e.g. “locale“: “sv-SE“) - Do NOT populate
contactId
3 - Arriving at product display page
What happens: The user enters a product display page (PDP) with multiple SKUs/colors/variants. What you need to do:- Avoid sending a productview for every size and instead send one when a specific size/colour/variant is picked
- If you want to track the view no matter the variant, then send a random SKU from the PDP. Or, as a last resort, send all variants. If all variants are sent, beware that you risk triggering abandoned browse emails containing many variants of the same product.
Verification and common issues
Here’s how to deal with a few common situations and issues connected to web tracking.1 - Verifying that tracking script is working
- Go to your e-com site.
- Open the JavaScript/developer console and go to “Sources”.
- Search for “analytics” and make sure you are using the latest script version.
- Go to “Application” → Cookies → the site that has implemented the tracking.
- If you are logged in/identified, look for the _val cookie
- If you are not logged in/identified then look for a _va cookie.
2 - Checklist for implementing the tracking script
Verify tracking script is loaded on non-product pages
Verify events are sent when anonymous and that no cookie exists
Verify events are sent when identified via an email link and that _vaI is correct
Verify that events are sent when identified via login and that _vaI is correctly
Verify that vaI is set correctly with and without a trailing slash in the URL
- Test with the slash: www.site.se/?vtid=LTq-P1eRKU2s8CWc5KPe5w
- Test without the slash: www.site.se?vtid=LTq-P1eRKU2s8CWc5KPe5w
- ALso navigate further into the site to verify that _vaI is not cleared.
Verify that the cookie _vaI is updated with a new vtid.
Verify that sessionid is set in the payload.


Verify tracking of product views
Here’s how to verify that tracking of your product views is working.- Go to your e-com site.
- Open the JavaScript/developer console, go to “Networks”, and select the Fetch/XHR tab.
- Visit any random product on the site.
- You should now see a call made to the Collect endpoint.
- In the payload, the te value should be your tenants/account name. Note that Locale does not have to be the same as the cart payload, and is not used in to identify anything.
- When viewing a product, the t (type) value should be “productview”, as pictured below.
- If you are logged in/identified, click on the payload and make sure the ci value is the same ID as in the _val cookie mentioned above. The value of ci should not be anything other than the ID.
Checklist for implementation of Product of Interest
Make sure itemId matches SKU
Verify that sessionid is set in the payload
Verify that the same events are not sent multiple times
Verify productview event when navigating to product page in different ways

Verifying cart changes


- Go to your e-com site.
- Open the JavaScript/developer console and go to “Networks” and select the Fetch/XHR tab.
- Place an item in the cart.
- You should now see a call made to an endpoint named Collect.
- In the payload, the t (type) value should be “cart”. Note the items[] array which may include products you’ve placed in your cart.
- If possible, complete the purchase / check out the cart.
- At this point a new Collect event should be fired with an empty cart indicating that the purchase has been made.
Cart tracking implementation checklist
Verify that cart events are sent with the correct language/locale
Verify cart event before checkout
Verify cart event in checkout
Common implementation errors
Cart event is not sent for every update
Different cartRef for the same cart
Multiple cart/productview events
Common implementation errors related to identification
Clearing the _vaI cookie when it is set with vtid
No cart/productview events before checkout or sign in
The _val cookie is not set when link in e-mail ends with slash (/).
Support for server-side cookies
The cookie _vaI (which stores contactId) is created client-side by the script. With Apple ITP (Intelligent Tracking Prevention) all client-side cookies (and LocalStorage) have a capped lifetime (7 days) in Safari. Which means when an identified visitor doesn’t revisit the site within 7 days the cookie will expire and the script wont be able to identify the visitor using the _vaI cookie. The cookie lifetime cap applies only to cookies created client-side (with Safari) and doesn’t affect server-side created cookies. The tracking script now support copying the value from a cookie _vaI_server created server-side as a fallback to recreate the client-side cookie _vaI. The cookie _vaI will be recreated, if needed, in this specific order:- The site invokes setContactId or includes contactId in an event
- The URL param vtid exists
- The LocalStorage key vtid exists
- The cookie _vaI_server exists
