The other day, Universal Analytics is out of beta status and is now becoming the main version of Google Analytics. This event allows you to use it without a number of restrictions that existed previously. The new version also carries a number of new features for tracking site visitors and provides an opportunity to compare user actions on the site and the subsequent execution of targeted actions offline.
For these purposes, use the Measurement Protocol or Data Transfer Protocol . When can you use this feature? I will give a couple of examples.
The first option is that a visitor purchases a product or service from your site, and at the same time selects the payment option “non-cash payment”. We can assume that the purchase process may not be completed for a number of reasons, so the transfer of information to Google Analytics about the transaction after completing the checkout / purchase process is incorrect. Data must be transferred after the actual payment.
')
The second option is cash payment to the courier upon delivery of goods. The purchase is considered completed after receipt of payment by courier.
In both situations, if we transmit data about the purchase (transaction) after the completion of the order process, we will distort the statistics, because we have no actual payment. To correct the situation with the excess recorded payments, you will have to use negative transactions, which is not always convenient and not entirely correct.
To solve this problem, we will be helped by a new feature that appeared in Google Analytics with the release of Universal Analytics, called Mesurement Protocol.
What is the principle of the protocol? It's quite simple: you need to send a specially crafted request to a specific URL.
1. v - protocol version, currently the value of 1 is used;
2. tid - Google Analytics tracking code (resource) identifier in the form UA-XXXX-Y;
3. cid - anonymous Client-ID;
4. t - hit type.
If the first and second parameters should not cause difficulties, then the third and fourth require clarification.
The cid parameter is an anonymous client-id or client identifier. If a visitor views your site using a browser, Universal Analytics will store the client-id value in a cookie, and if you don’t know the value, use any of your own.
Please note that if you use a client-id, which is obtained from a cookie file, the transferred data will be matched with other actions of the visitor, and if you transfer your value, then a certain hit of the new visitor will be recorded (operations under one client-id are assigned to one visitor) . For an illustration of this, look at the image:
Viewing the page at number 1 is the first visit to the site, viewing 2 is generated using the Mesurement Protocol by clicking on the button (using the clid from the cookie set in visiting number 1). We have a report on the site will be 1 visitor.
View 3, as well as view 2, was generated by clicking on a button, with the value 12345 being transmitted as clid, which results in the appearance of a second visitor on the site. According to the report, we already have 2 visitors. View 4 is completely similar to view 2 (this is the action of visitor number 1, which previously made views 1 and 2).
Let's return to the parameters. The next parameter is t (this is the hit type). It can take a limited range of values ​​- 'pageview', 'appview', 'event', 'transaction', 'item', 'social', 'exception', 'timing'.
The most commonly used values ​​are:
pageview - page view;
event - event;
transaction - transaction;
item is a transaction item.
Already, you have the ability to transfer data to Universal Analytics using the Measurement Protocol. But in order for us to receive reliable and complete information in the reports, two more steps are needed :
1. Get the client-id of the site visitor and save it to CRM along with the order data (compare the user's activity on the site and its offline actions).
2. Supplement the request with additional parameters that allow us to work with the transmitted data in the reports.
You can get clien-id from Universal Analytics cookie:
You can independently or with the help of developers get the desired value. I use the following PHP code in my work (by Matt Clarke):
<?php/* * Name: Universal Analytics Cookie Parser Class * Description: Parses the new format Universal Analytics cookie. * Developer: Matt Clarke * Date: January 10, 2013 */classUniversalAnalyticsCookieParser{ // Parse the _ga cookie if found function __construct() { if( isset($_COOKIE["_ga"]) ){ echo $this->getCid(); } } // Handle the parsing of the _ga cookie public function parseCookie() { list($version,$domainDepth, $cid1, $cid2) = split('[\.]', $_COOKIE["_ga"],4); return array('version' => $version, 'domainDepth' => $domainDepth, 'cid' => $cid1.'.'.$cid2); } // Get cid public function getCid() { $contents = $this->parseCookie(); return $contents['cid']; } }?>
As for the additional parameters, there are a lot of them, some of them with a description in Russian can be found here , and the full list is available in the official Google Analytics documentation.
Consider some of the parameters that relate to previously designated types of hits.
dh - the domain name of the site;
dp - the address of the page relative to the domain name of the site;
dt - page title;
ec - event category;
ea - event action;
el - event label;
ti is a transaction identifier;
ta is the name of the branch or store;
tr is the total amount of the transaction;
in - the name of the product;
ip - the cost of the goods;
iv - product category.
Now that we have everything we need to use the Measurement Protocol , we can try the acquired knowledge in practice. We will use all the types of hits that were previously named. I will demonstrate data transfer by sending queries using jQuery.
Please note that in order to send purchase data, you must first transfer data about the transaction, and then about each item.
At what point do you need to transfer data using the Mesurement Protocol? For the examples that I gave at the very beginning of the publication, the transfer of the application to CRM from the status “order is delivered” to “order paid” can be the moment of data transfer. Developers, if they have the necessary data, it will not be difficult to send a generated request for a specific action or event on the site.
As you can see, there is no difficulty in using this functionality of Universal Analytics. Use it to collect reliable data and optimize your business.
For complete and official information, refer to the documentation.
In conclusion, I will give an example of a video clip that demonstrates the recording of events and the transfer of information to Universal Analytics for a motion sensor: