Step 3. Integration of Universal Analytics with RetailCRM
Copy the link to the article


Orders are exported from the store from the server side of the site. The export is configured by the store developer using API.

Orders to be exported may contain:

  • External ID (externalId);
  • Internal ID (id);
  • Order number (number).

From the store to Universal Analytics, data is exported from the clustomer's side, directly from the store visitor's computer.

This data consists of two parts:

  • Information about visits, obtained thanks to the tracking code, which is placed on each page of the site;
  • Transactions containing order information.

The code that uploads transactions should only be executed when the order is confirmed by the user.

Transactions contain a unique (within the store) identification number (transaction ID). It must match the external or internal ID or order number in the data uploaded to the system. This is required to bind Universal Analytics transaction data with data within the system.

Steps required to integrate with Universal Analytics

For correct integration with Universal Analytics, follow these steps:

1. Get the ID of an online store view in Universal Analytics. To do this, in Universal Analytics go to "View settings" and copy the "View ID".

2 . In the system, go to the "Integration" section.

3 . Open the integration module with Universal Analytics (in the marketplace) and activate it.

4. Specify which data that is uploaded from the store to the system corresponds to the transaction ID.


If no order number is set when uploading data, it will be generated automatically based on the external ID. In this case, the transaction ID must correspond to the external ID of the order, and in the integration settings, you must specify the binding via the external ID.

5. Add a custom parameter/variable that is needed to store the visit data.

Go to the section Administrator > Resource > Custom definitions > Custom parameters and add the retailCRMVisitorID parameter. The parameter will be assigned an index number to remember.

6. Specify the ID of Universal Analytics profile/view in the integration module.

In addition to the ID of the Universal Analytics profile/view, in the module settings, you will need to enter the index number that appeared when adding a custom parameter.

The checkbox "Translate common source and mediums" allows you to display sources and channels in the common spelling. That is, instead of, Yandex.Mail will be displayed.

7. Copy the system username. It is a robot collecting data from Universal Analytics for the system.

8. Add user to Universal Analytics account. In Universal Analytics, select Administrator > Account > User management. The added user must have the "Read and Analyze" rights.

9. Add a function to the Universal Analytics counter code (skip this step if you are using gtag.js).

/* Get cookie value by name. RetailCRM integration with Universal
Analytics uses it.
* Name should match pattern [a-zA-Z0-9_]+
* @param string name
* @return mixed
function getRetailCrmCookie(name) {
var matches = document.cookie.match(new RegExp(
'(?:^|; )' + name + '=([^;]*)'

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

ga('set', 'dimension1', getRetailCrmCookie('_ga'));

You will need to insert the function before ga('send', 'pageview'); in the tracking code on all pages of the site.


In the last line of the added code, ga ('set', 'dimension1', getRetailCrmCookie ('\ _ ga')); , the digit 1 at the end of dimension 1 must be replaced with the index of the custom parameter in case it is not is equal to 1.

Universal Analytics identifies website visitors using temporary cookies, which are stored on the user's computer. One of them contains a unique user label. The script that is added to the tracking code reads the unique label and then sends that value to Universal Analytics, where it is stored in a custom variable (in the Client ID custom parameter in Universal Analytics).

Cookie _ga contains a unique identifier in the format GA1.2.XXXXXXX.YYYYYY, eg GA1.2.1129978185.1425645525, where the label itself is only the value 1129978185.1425645525 (clientId). You can pass both the full cookie value to the system (which will happen if you use the above-mentioned code), or only the clientId without a prefix.

10. After setting up integration with Universal Analytics, on the integration page in the system, will appear the dates when the last upload of the following was made:

  • sources,
  • visits,
  • funnel events.

Uploading data on events

For example, in addition to a purchase in a store, a visitor can order a call or fill in a feedback form. This creates an order in RetailCRM. However, you do not want to create a transaction in the Universal Analytics ecommerce module because the corresponding event is not a purchase. In this case, in Universal Analytics, you can set up an event and collect web analytics data for this customer via it (ClientID, sources, campaigns, channels, visits, keyword and campaign content).

If the option of linking orders via events is selected, two data entry fields for uploading events will appear below: "Category" and "Actions".

In these fields, you must specify the categories and actions for events, in the labels of which identifiers corresponding to orders in the system are transferred. You can specify only a category or only a label, in this case, no filtering of uploaded events will be performed by another field.


It is necessary to fill in the category and action, but the label must be left blank, because it will send the order ID for communication. On the site side, for the desired action (click, form submission, etc.), register the sending of events to Universal Analytics. Be sure to include the order ID as the label.

How to create, modify and publish targets can be found in Google help.

Thank you for your feedback.
Was this article helpful?
  • Рекомендации не помогли
  • Нет ответа на мой вопрос
  • Текст трудно понять
  • Не нравится описанный функционал
Previous article
Step 2. Configuring e-commerce tracking for Universal Analytics account
After registering your account in Universal Analytics, you need to configure ecommerce tracking. The Universal Analytics tracking code is in JavaScript script and run by a site visitor's browser.
Next article
Uploading data from the system to Universal Analytics
The article describes the the transfer of offline order information to Universal Analytics.