Manually adding the tracking script to a web page

Kristian Graae West Larsen -

The Raptor tracking script consists of two parts:

  1. A header script, that is put into the <body></body> , and
  2. a tracking script, that tracks events. The tracking script can be put anywhere inside the <body> tags

The Raptor script

Must be put inside the <body></body> tags on ALL pages
<script>

        (function (d, t) {
            var g = d.createElement(t),
                s = d.getElementsByTagName(t)[0];
            g.src = '//az19942.vo.msecnd.net/script/raptor-2.1.3.js';
g.async = true;
            s.parentNode.insertBefore(g, s);
        }(document, 'script'));
    </script>

The tracking script

Can be put anywhere within the <body> tags. The tracking script should be put on all product pages, category pages, basket page, and checkout page. Read more about the events further down the page 
 
NB: This is just an example, and not the actual script to use. Please log into our controlpanel and find your specific version of the tracking script.
<script type="text/javascript" language="javascript">      
var raptorLoaded = function (raptor) {
raptor.initialize({
customerID: "{YOURCUSTOMERID}",
productIdParamIndex: 2, //Refer to controlpanel for precise value
eventTypeParamIndex: 1 //Refer to controlpanel for precise value });

raptor.trackEvent(...,..., ...); //Read more about the tracking events below
}
</script>



raptor.Initialize Parameters

the raptor.Initialize function sends key information as a JSON object, used for identifying your account setup. Please refer to your account in the Raptor Controlpanel, for obtaining these values

 

customerID The customer account ID.
productIdParamIndex The position of the product ID parameter in list of tracking parameters. 
eventTypeParamIndex The position of the eventtype parameter in the list of tracking parameters.
userQueryParamName (Optional) The Raptor script will automatically track a parameter in the querystring, called "ruid", which can be used for tracking users coming from an external source (for instance, an email). However, if you already have a parameter with a userid that your system is using, you can tell us the name of this parameter, and we will use that in our "ExternalUserId" tracking parameter.

raptor.trackEvent Parameters

These parameters can vary from customer to customer. You will find the precise order and list of parameters in the Raptor Controlpanel here.

An raptor.trackEvent should be fired for each of these 3 scenarios:

Best practices:

  • Send us the master product id in the trackings. Then you will get recommendations on the main product, not the variants 
  • If you have integrated a product feed with our engine, take care that the product id match the product id in the product feed, otherwise the recommendation modules will not be able to find the products in the product catalog.

 

FAQ

 

Do I need to send all product information for all events?

The short answer is "No". 

  • For visit events, all we basically need is a productId, and a category path
  • For basket events, we need a list of product id's in the basket.
    Read more about basket tracking here
  • For buy events, we need a product id, the total price of the product (i.e: the product price x quantity), and the currency.

 

What if the user buys more than 1 item?

If the user buys multiple items of the same product, just put the total price in the buy event (i.e: the product price x quantity)

If the user buys multiple different items, put a raptor.trackEvent for every item in the basket

 

How can I check that the tracking script works?

When you have finished setting up the tracking script on the web pages, then you can immediately see the trackings generated on the website, by clicking into our controlpanel.

See below "Tracking Scripts --> Last trackings", and you will find a realtime updated view of the tracking flow in the Raptor Engine.

 Which cookies does the Raptor Script set on the client?

The Raptor scripts set the following cookies for different purposes. The main purpose is to add personalization to the raptor module.

[customerId]rsa Cookie for tracking user behavior Set on the customer domain 1 year
[customerId]rsaSession Cookie for tracking user behavior Set on the customer domain 30 minutes
rsa Cookie for tracking user behavior Set on *.raptorsmartadvisor.com domain 1 year
[customerId]rsaRuid Cookie for tracking user behavior Set on the customer domain 1 year
Have more questions? Submit a request

Comments

Powered by Zendesk