Specifics of configuring an integration between Universal Analytics and InSales This article describes the specifics of adding a tracking code to InSales CMS. false W3sidGl0bGUiOiJJbnRlZ3JhdGlvbiIsInVybCI6Ii91c2Vycy9pbnRlZ3JhdGlvbi8ifSx7InRpdGxlIjoiQW5hbHl0aWNhbCBzZXJ2aWNlcyIsInVybCI6Ii91c2Vycy9pbnRlZ3JhdGlvbi9hbmFseXRpY2FsLXNlcnZpY2VzLyJ9LHsidGl0bGUiOiJJbnRlZ3JhdGlvbiB3aXRoIEdvb2dsZSBBbmFseXRpY3MgKEdBNCkiLCJ1cmwiOiIvdXNlcnMvaW50ZWdyYXRpb24vYW5hbHl0aWNhbC1zZXJ2aWNlcy9pbnRlZ3JhdGlvbi13aXRoLWdvb2dsZS1hbmFseXRpY3MvIn1d Integration /users/integration/ ["users","Integration"] ["users","Integration","Analytical services"] users

Specifics of configuring an integration between Universal Analytics and InSales

This article describes the specifics of adding a tracking code to InSales CMS.

The tracking code is added to the “javascript code” field, which is located in the CMS settings, for displaying on all pages of the store.

Example (in all examples XXXXXXXXX will need to be replaced with a real resource identifier!):

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new
Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'XXXXXXXXX', 'auto');

function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([.$?*|{}()[]/+^])/g, '$1') + "=([^;]*)"
));

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

ga('set', 'dimension1', getCookie("_ga"));
ga('send', 'pageview');
</script>

Since InSales does not place this code at the top of the page, you need to duplicate it. Therefore, the transaction uploade code must be placed in the “javascript code” field to be displayed on the successful checkout page by adding the above-mentioned code at the beginning (and duplicating it within the page).

Example:

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new
Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXXXXX-X', 'auto');

function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') +
"=([^;]*)"
));

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

ga('set', 'dimension1', getCookie("_ga"));
ga('send', 'pageview');

// UA transaction upload code starts here
ga('require', 'ecommerce', 'ecommerce.js');
ga('ecommerce:addTransaction', {
'id': {{order.number}},
'affiliation': 'site.ru', // replace with real domain name
'revenue': {{order.total_price}}
});
{% for item in order.items %}
ga('ecommerce:addItem', {
'id': {{order.number}},
'price': {{item.sale_price}},
'quantity': {{item.quantity}}
});
{% endfor %}
ga('ecommerce:send');
</script>

Important!

When integrating with InSales, in the analytics settings, activate the “Link transactions via Order number” option. In the settings of InSales, you will also see the “Google Analytics code for analyzing visitors on the site” field. You don’t need to fill this in: firstly, the GA code will be generated, not the UA code. Secondly, the code will be generated “from the standard module” and will not allow the adding of a unique label entry from the cookie to custom dimension.
Thank you for your feedback.
Was this article helpful?
No
  • The recommendations did not help
  • There is no answer to my question
  • The text is difficult to understand
  • I do not like the described functionality
Yes
Next article
Sending a transaction using Daemon Collector
This article describes the principles of transferring transactions using the Daemon Collector technology.