⬆️ ⬇️

E-commerce in Universal Analytics

image

On Habré already wrote ( 1 , 2 ) about Universal Analytics from Google.

Electronic commerce and tracking of events on the website are the main functions of analysts of online stores and companies that track the sale of goods and services. In this topic, we consider their configuration for Universal Analytics.



Comparison of Universal and the classic version of Google Analytics.



image



A few more innovations that are not reflected in the table:



The way in which user variables are used has changed. Previously, the names and actions of the parameters were indicated in the code, in Universal Analytics this should be done in the settings. Tab “Administrator” -> “User parameters” and “Administrator” -> “User indicators”

')

Configure e-commerce



1. To start tracking e-commerce in Universal Analytics, you must first enable it in your profile settings. To do this, go to the tab “Administrator” -> “View Settings”. On this tab, you must specify the country, currency, enable e-commerce and you can also set up tracking of search queries of users on the site.



2. Place the e-commerce code on the order confirmation page.

First you should place the main code of Universal Analytics, if it is not already on the site. You can find it in the “Administrator” tab -> “Tracking code”. It looks like this, but instead of UA-XXXXXXXX-1 you should substitute your ID.



(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-1', 'example.com'); ga('send', 'pageview'); 


Then the e-commerce code that will send the data:



 ga('require', 'ecommerce', 'ecommerce.js'); ga('ecommerce:addTransaction', { 'id': '1234', // ID  'affiliation': 'example.com', //   'revenue': '1500', //    'shipping': '250', //   'tax': '' //  }); // addItem      ()      addTransaction  id. ga('ecommerce:addItem', { 'id': '1234', // ID  'name': 'Mouse Logitech', //   'sku': 'AAA000', //   SKU 'category': 'Wireless', // , ,    -  'price': '750', //   'quantity': '2' //   }); ga('ecommerce:send'); //   


Negative transactions are also created, i.e. negative numbers are used when placing the order.



Configure Event Tracking



Also common action in Universal Analytics is event tracking. Using them, you can track: clicks, work with forms, view videos, upload and download files, etc. The most common event for tracking in e-commerce - the user added to the basket product / service. In order for this data to be displayed in Universal Analytics, the following code should be executed:



 ga('send', 'event', '', '', '',  ()); 


Description of parameters:

Category - similar actions on the site, for example, “Basket”.

Action - designation of a specific event / action on the site, for example, “added to the basket” and “deleted from the basket”

Label - an additional description of the action, for example, “click on the item card” and “click from quick view”

Value is a numeric value that will be useful to you in the analysis.

“Category” and “Action” are required parameters.



An example of using event tracking with jQuery:



 $('#add_to_basket').on('click', function() { ga('send', 'event', '', '  ', '   '); }); 


That's all, consider, analyze, disable traffic sources that do not bring orders.



PS If you have questions or topics for topics on this topic, then I ask in the LAN.



Materials and useful resources:

Source: https://habr.com/ru/post/202824/



All Articles