Why tracking codes are needed
The Retail Rocket system calculates product recommendations by analyzing user behavior on the site. This takes into account product or category views, adding products to the cart, and orders. Tracking codes are installed on the site to collect statistics, based on which recommendations are calculated. Therefore, the recommendation calculation process directly depends on the correct installation of trackers.
Please refer to the section "Instructions for CMS", where you can find instructions for popular versions of websites.
In addition to analysis, tracking codes are used to send trigger emails. Sending an email (for most scenarios) occurs when two conditions are met:
- the user left their email on the site,
- the user performed an action that triggered a trigger, for example, viewed a product.
Principles of tracking code installation and operation
Tracker codes are integrated into the store's website code on specific pages. The product card view tracker is installed only in the template for product pages, the category view tracker - in the template for product category pages, the add to cart tracker - in the templates of pages where there are "Buy" or "Add to Cart" buttons, and the order tracker - in the "order placed" or "thank you for your order" page template.
It should be noted that the site may have additional functionality: a pop-up window for quick product viewing, a "quick" order form or a "1-click" order. In this case, it is necessary to additionally install the product view tracker in the quick view window template, and additionally call the order tracker when placing orders through quick order forms.
In the main tracking code, system variables and functions that will be used by other RetailRocket trackers and components are defined. Therefore, for the correct operation of the service, the main tracker must be installed on all pages of the site in such a way that it is located in the code before other trackers. We recommend placing it in the <head> section or at the very beginning of the <body> section, before the main content of the page.
The following functions are used in tracking codes to track product events:
- rrApi.view(product_id) – product view,
- rrApi.categoryView(category_id) – product category view,
- rrApi.addToBasket(product_id) – adding a product to the cart,
- rrApi.order(transaction: “id”, items: array[]) – placing an order.
In all these functions, the product or category ID is passed as a parameter (in the order tracker, the order ID and an array of purchased products are used), which must consist only of Arabic numerals, and its value should not be greater than 9,007,199,254,740,991.
When these functions are called on the site, requests are sent to Retail Rocket, by analyzing which the system understands what actions the user performed and with which products they interacted.
There is also a tracker for transferring user emails to Retail Rocket. It calls the function
- rrApi.setEmail(email)
where email is a string variable containing the email address. This tracker must be installed on all forms on the site where the user can enter their email. These include forms on order placement, registration, and authorization pages. If the site has additional subscription forms, the email collection tracker must also be installed on these forms. Please note that only the addresses of users who have explicitly consented to receive emails should be sent to the system.
You can learn more about diagnosing tracking codes in the article: "Checking the operation of tracking codes".