Step 2. Configuring e-commerce tracking for Universal Analytics account
Copy the link to the article
Copied

After registering an account in Universal Analytics, you need to set up ecommerce tracking.

If you have already done this, you can go to "Integration with the system".

Note

Universal Analytics does not run in the demo version of the system.

Settings in Universal Analytics

To enable ecommerce tracking in Universal Analytics, follow these steps:

  1. Go to the "Administrator" section.
  2. In the "View" column, select "Customise View. 3. In "Ecommerce Settings", select Ecommerce tracking.
  3. Click the "Apply" button.

An important point in this section is configuring the of your currency. You need to set the same currency as selected and used in RetailCRM.

For information on how to set up e-commerce tracking, see Google Help.

Getting a tracking code

The Universal Analytics tracking code is in JavaScript script and is run by a site visitor's browser. Using the tracking code, data about the visitor's actions on the site will be sent to Google Analytics.

For how information on how to get the tracking code, see Google Help.

Copy the complete tracking code from Universal Analytics. Instead of UA-XXXXXXXX-X, a valid tracking ID will be displayed.

In case of using gtag.js the code must be modified in this way:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script>
 window.dataLayer = window.dataLayer || [];
 function gtag(){dataLayer.push(arguments);}
 gtag('js', new Date());

 function getRetailCrmCookie(name) {
 var matches = document.cookie.match(new RegExp(
 '(?:^|; )' + name + '=([^;]*)'
 ));

 return matches ? decodeURIComponent(matches[1]) : '';
 }

 gtag('config', 'UA-XXXXXXXX-X', {
 'custom_map': {'dimension1': getRetailCrmCookie(“_ga”)}
});

</script>

Important!

In the last string of the added code: 'custommap': {'dimension1': getRetailCrmCookie (“ ga”)}, the digit 1 at the end of dimension1 must be replaced with the index of the custom parameter if it is not equal to 1.

Site settings

Next, you should add the tracking code to the site pages by copying it to all site pages before the closing tag </head>.

In order for Universal Analytics to receive information about completed orders, you need to modify the tracking code on the user's notification page about the completion of the order, adding information about the order.

You only need to modify the code on the pages that the user sees after completing/confirming the order. Thus, the modified code should only be executed once for each new order.

Unlike the modified one, the normal tracking code must be executed every time the page is viewed where the code is added.

For Universal Analytics, you need to modify the tracking code as follows:

<script type="text/javascript">
 ...
 ga('send', 'pageview'); // this is where the unmodified tracking code ends. Add the following commands:

 ga ('require', 'ecommerce', 'ecommerce.js'); // function that connects the e-commerce module.
  ga ('ecommerce: addTransaction', {
  'id': '1234', // Transaction ID
  'affiliation': 'example.com', // Store name
  'revenue': '1500', // Total order value
  'shipping': '250', // Delivery cost
  'tax': '' // Tax
  });

// the addItem method must be called for each product (item) in the order:
  ga ('ecommerce: addItem', {
  'id': '1234', // Transaction ID
  'name': 'Mouse Logitech', // Product name
  'sku': 'AAA000', // Article or SKU
  'category': 'Wireless', // Size, model, category or some other information
  'price': '750', // Product cost
  'quantity': '2' // Product quantity
  });

 ga('ecommerce:send'); // Data sending
</script>

In this code, you can specify fields in any order. Only the fields containing the transaction ID and product name are required. Field names must be in lower case letters, i.e category, not Category, and not CATEGORY.

The following functions are visible in the code:

ga('require', 'ecommerce', 'ecommerce.js'); - is a function that connects the e-commerce module.

ga('ecommerce:addTransaction' - is a function that transfers information about the order itself.

Fields to be passed to the function:

    • Transaction ID * - number. Mandatory parameter that contains the order identifier (for example, "1234"). If the site is on 1C-Bitrix, then the value must match the order ID in 1C-Bitrix. This value must correspond to the number or ID (external or internal) of the order uploaded to the system. Read more about this in the next article "Integration with the system.
  • Affiliation - string. An optional parameter that contains the name of the store (for example, "example.com")
  • Revenue - number. An optional parameter that contains the total cost of the order (for example, "1500")
  • Shipping - number. An optional parameter that contains the delivery cost (for example, "250")
    • Tax * - number. An optional parameter that passes the tax amount.

ga('ecommerce:addItem', - a function that transfers information about products in an order.

Fields to be passed to the function:

    • Transaction ID * - number. Mandatory parameter that contains the order identifier (for example, "1234"). If the site is on 1C-Bitrix, then the value must match the order ID in 1C-Bitrix. This value must correspond to the number or ID (external or internal) of the order uploaded to the system. Read more about this in the next article "Integration with the system".
  • Name - string. Mandatory parameter that contains the name of the product (for example, "Mouse Logitech")
  • SKU - string. An optional parameter in which the product article is passed (for example, "AAA000")
  • Category - string. An optional parameter in which the product category is passed (for example, "Wireless")
    • Price * - number. An optional parameter, in which the cost of the product is passed (for example, "750")
  • Quantity - number. An optional parameter, in which the quantity of a product is passed (for example, "2")

ga('ecommerce:send'); - function that confirms sending data.

If using gtag.js, you need to modify the tracking code as follows:

<script type="text/javascript">
gtag('event', 'purchase', {
"transaction_id": '1234', // Transaction ID
  "dimension1": getRetailCrmCookie ("_ ga"), // Custom parameter
  "affiliation": 'example.com', // Store name
  "value": 23.07, // Event value
  "tax": 1.24, // Tax
  "shipping": 0, // Delivery cost
  "items": // Array with products
 [{
"id": "1234", // Unique identifier of the product
  "name": "Mouse Logitech", // Product name
  "category": "Wireless", // Product category
  "quantity": 2, // Number of product units
  "price": '750' // Purchase price of the product
 }]
});
</script>

In this code, you can specify fields in any order. Only the fields containing the transaction ID and product name are required. Field names must be in lowercase Latin letters, eg category, not Category, and not CATEGORY.

Fields to be passed to the function:

    • Transaction ID * - number. Mandatory parameter that contains the order identifier (for example, "1234"). If the site is on 1C-Bitrix, then the value must match the order ID in 1C-Bitrix. This value must correspond to the number or ID (external or internal) of the order uploaded to the system.
  • dimension1 - custom parameter, optional for filling in. Its passing is required to upload the clientId into the system
  • Affiliation - string. An optional parameter that contains the name of the store (for example, "example.com")
  • Value - number. An optional parameter that contains the total cost of the order (for example, "1500")
  • Shipping - number. An optional parameter that contains the delivery cost (for example, "250")
  • Tax - number. An optional parameter that passes the tax amount.

Fields to be passed to the function:

  • Transaction ID - number. Mandatory parameter that contains the order identifier (for example, "1234"). If the site is on 1C-Bitrix, then the value must match the order ID in 1C-Bitrix. This value must correspond to the number or ID (external or internal) of the order uploaded to the system.
  • Name - string. Mandatory parameter that contains the name of the product (for example, "Mouse Logitech")
  • Category - string. An optional parameter in which the product category is passed (for example, "Wireless")
  • Price - number. An optional parameter, in which the cost of the product is passed (for example, "750")
  • Quantity - number. An optional parameter, in which the quantity of products is passed (for example, "2")

A full list of possible fields can be found in the official documentation

Thank you for your feedback.
Was this article helpful?
No
  • Рекомендации не помогли
  • Нет ответа на мой вопрос
  • Текст трудно понять
  • Не нравится описанный функционал
Yes
Previous article
Step 1. Adding a site to Universal Analytics
Universal Analytics is an advanced Google Analytics standard for tracking source information.
Next article
Step 3. Integration of Universal Analytics with RetailCRM
The article describes how data is uploaded from a store in Universal Analytics to your system and how to configure it so that all parameters are uploaded in full.
#}