Understanding Universal Analytics Measurement Protocol

 

Here is what you will learn through this post:

Learn (in plain English) to send data to Universal Analytics using the measurement protocol.

Learn to send event tracking data and e-commerce data to Universal Analytics.

If you are new to universal analytics, I would strong suggest to read this post first:

Beginners Guide to Universal Analytics – Creating Custom Dimensions & Metrics.

It explains the major difference between Google Analytics and Universal Analytics and it also explain in great detail about creating custom dimensions and metrics.

 

What is a measurement protocol and why do you need it?

Universal Analytics (UA) provides more ways to collect and integrate different types of data than Google Analytics (GA). That is why we use UA, to collect and integrate the data which can’t be easily collected and integrated through GA.

For example we can collect and integrate data from digital appliances (like washing machine) or point of purchase system through UA. This is not possible through GA.

However in order to really benefit from UA, you need to know and follow the ‘Measurement Protocol’.

Measurement protocol is a set of rules which Universal Analytics use to collect data from any device or system.

This device/system can be a smart phone, tablet PC, digital appliance (like washing machine, coffee machine), point of purchase etc.

Unless your data is not formatted according to the measurement protocol, it can’t be sent to the Universal Analytics Servers.

So if you want to send data from your washing machine to the Universal Analytics servers, you first need to format the data according to the measurement protocol.

Similarly, the data from your cash counter machine or coffee machine or slot machine can’t be sent to UA servers, if it is not formatted according to the measurement protocol.

So measurement protocol is very important. Without this protocol there is no real benefit of using universal analytics.

Note: You can collect and send only user interaction (event, hit) using the measurement protocol.

 

Sending User Interaction data using the Measurement Protocol

In order to send user interaction data (event, hit) using the measurement protocol, you should ideally take the help of your web developer.

Your web developer can create an application which can retrieve data from your desired data source (like cash machine), convert that data into Payload data (which is basically the process of formatting the data according to the measurement protocol) and send it to the UA server either through GET or POST HTTP request.

measurement-protocol

Payload data is the data you send to Universal Analytics server using the measurement protocol.

In other words, the payload data is the data which has been formatted according to Measurement Protocol.

Following is an example of payload data:

v=1&tid=UA-123456-2&cid=36009a59-2a05-49e7-b826-2b884d0f935b&t=pageview&dp=%2Fhome

 

Transport defines where and how to send the payload data.

Generally the payload data is send to: http://www.google-analytics.com/collect.

However if you want to send the payload data via a secure connection (over SSL), then you need to send the data to: https://ssl.google-analytics.com/collect

You can send payload data by using either GET or POST HTTP request.

However POST method is preferred, as you can send larger payload data to Universal Analytics server.

Following is the syntax of sending Payload data to Google Analytics Server using the measurement protocol:

 User-Agent: user_agent_string

POST http://www.google-analytics.com/collect?[payload_data]

 

For example:

User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36

POST http://www.google-analytics.com/collect?v=1&tid=UA-123456-2&cid=36009a59-2a05-49e7-b826-2b884d0f935b&t=pageview&dp=%2Fhome

Here we are sending pageview data for the home page to the Universal Analytics server.

 

The ‘Payload data’

Payload data is the data you send to Universal Analytics server using the measurement protocol.

The payload data resembles a URL query string (query string is the part of the URL which comes after the ‘?’ Character) and is made up of parameter=value pairs. Each parameter=value pair is separated by ‘&’ character.

Syntax of payload data:

parameter1=value1&parameter2=value2&parameter3=value3

Example of payload data:

v=1&tid=UA-123456-2&cid=36009a59-2a05-49e7-b826-2b884d0f935b&t=pageview&dp=%2Fhome

Here v, tid, cid, t and dp are parameters.

1, UA-123456-2, 36009a59-2a05-49e7-b826-2b884d0f935b, pageview and %2Fhome are values of the parameters.

The character ‘&’ has been used to separate each parameter=value pair

 

Each payload data must contain following parameters

1. v – It is used to denote the measurement protocol version. The value of this parameter should be 1. For example: v=1

2. tid – It is used to denote the tracking ID. The value of this parameter should be the property ID of the Google Analytics property where you want to send the payload data. For example: tid=UA-123456-2

 3. cid -  It is used to denote the client ID (ID which anonymously identifies a particular user, device, or browser and is unique to a particular visitor/user). The value of this parameter should be a random Universally Unique IDentifier (UUID) as described here http://www.ietf.org/rfc/rfc4122.txt

For example: cid = 36009a59-2a05-49e7-b826-2b884d0f935b

4. t – It is used to denote the hit type. The value of this parameter should be anyone of the following: ‘pageview’, ‘event’, ‘social’, ‘transaction’, ‘item’, ‘exception’,’appview’ or ‘timing’

For example: t= pageview or t= event or t= social or t= transaction or t= item

 

The ‘Transport’

Once you have your payload data, you then need to create a ‘transport’. Transport defines where and how to send the payload data.

Generally the payload data is send to: http://www.google-analytics.com/collect

However if you want to send the payload data via a secure connection (over SSL), then you need to send the data to: https://ssl.google-analytics.com/collect

You can send payload data by using either GET or POST HTTP request. However by using POST, you can send larger payload data to Google Analytics server.

transport-payload-data

Here we are sending pageview data for the home page to the Google Analytics server.

 

List of Parameters which are commonly used in payload data

 

Parameter

Description

Value

Example

1

dr

Document Referrer,

the referral source which brought traffic to your website.

The value of this parameter should be a URL (URL encoded)

dr=http%3A%2F%2Fabc.com

 

All values of the parameters must be URL encoded before they are sent to the Google Analytics server. For this reason the URL http://abc.com has been first encoded to http%3A%2F%2Fabc.com before it is passed as a value to the ‘dr’ parameter.

 

2

cn

campaign name

The value of this parameter should be a URL encoded text string.

cn=attribution

 

3

cs

campaign source

URL encoded text string.

cs=%28direct%29

 

Here the campaign source is ‘(direct)’. But when the text string is URL encoded the opening parenthesis ‘(‘ is replaced by ‘%28′ and the closing parenthesis is replaced by ‘%29′

 

4

cm

campaign medium

URL encoded text string.

cm=organic

 

5

ck

campaign keyword

URL encoded text string

ck=event%20education

 

6

cc

campaign content

URL encoded text string

cc=top%20left

 

7

dl

document location,

the full URL of the page which contains the contents

URL (URL encoded)

dl=http%3A%2F%2Fexample.com%2Fhangers%3Fprod%3D231

 

Here the original value (before URL encoding) is: http://example.com/hangers?prod=231

8

dh

document hostname,

the host where the contents are hosted.

Hostname

dh=example.com

 

9

dp

document path

The value of this parameter should begin with /

 

dp=%2Fhangers%3Fprod%3D231

 

Here the original value (before URL encoding) is: /hangers?prod=231

10

dt

document title

URL encoded text string

dt=event%20education%20courses

 

Here the original value (before URL encoding) is: event education courses

11

ec

Event category

URL encoded text string

ec=videos

 

12

ea

Event Action

URL encoded text string

ea=play

 

13

el

Event Label

URL encoded text string

el=spider%20man

 

14

ev

Event Value

Integer value

ev=100

 

15

ti

e-commerce transaction ID

URL encoded text string

ti=4567DT

16

ta

Transaction affiliation,

denotes the store name

URL encoded text string

ta=tesco

17

tr

Transaction revenue

Currency

tr=45.56

 

18

ts

Transaction shipping

Currency

ts=2.32

 

19

tt

Transaction tax

Currency

tt=10.11

20

in

Item name, the name of the product item

URL encoded text string

in=hangers

21

ip

Item price, the price of a single product item

Currency

ip=34.21

22

iq

Item quantity, the number of product items purchased.

Integer

iq=45

23

ic

Item code, this is the product SKU

URL encoded text string

ic=23ds53

24

iv

Item category, the category to which the item belongs to

URL encoded text string

iv=retail%20display

25

cu

Currency code, the currency used for all the transactions

URL encoded text string

cu=EUR

Note (1): You can learn more about URL encoding from here: http://www.w3schools.com/tags/ref_urlencode.asp

Note (2): All text values have size limit which is expressed in bytes.

Note (3): You can get complete list of all of the parameters from here.

 

Sending Event Tracking data to Universal Analytics server using measurement protocol

One of the big downside of using Universal Analytics is that implementation of almost everything from cross domain tracking, event tracking to e-commerce tracking requires good amount of technical knowledge and there is not enough support available from Google and other analytics users yet.

In order to send event tracking data to UA server, you need to send following similar HTTP POST request for each unique event:

User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36

POST http://www.google-analytics.com/collect?v=1&tid=UA-123456-2&cid=36009a59-2a05-49e7-b826-2b884d0f935b &t=event&ec=video&ea=play&el=spider%20man&ev=100

 

Sending Ecommerce data to Universal Analytics server using measurement protocol

To send ecommerce tracking data, you need to send one HTTP POST request for an entire transaction and one HTTP POST request for each item in the transaction. For example:

HTTP POST request for an entire transaction

User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36

POST http://www.google-analytics.com/collect?v=1&tid=UA-123456-2&cid=36009a59-2a05-49e7-b826-2b884d0f935b&t=transaction&ti=4567DT&ta=tesco&tr=45.56&ts=2.32&tt=10.11&cu=EUR

 

HTTP POST request for one item in the transaction

User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36

POST http://www.google-analytics.com/collect?v=1&tid=UA-123456-2&cid=36009a59-2a05-49e7-b826-2b884d0f935b&t=item&ti=4567DT&in=hangers&ip=34.21&iq=45&ic=23ds53&iv=retail%20display&cu=EUR

 

Note: You need to use the same transaction ID to associate a product item with a transaction.

 

If you have any question or you would like to share your knowledge/expertise then please do so in the comment section below.

Other posts you will find informative: 

Advanced Attribution Modelling in Google Analytics

How to use Agile Analytics to quickly solve your Conversion problems 

 

Himanshu Sharma About the Author: is the founder of seotakeaways.com which provides SEO Consulting, PPC Management and Analytics Consulting services to medium and large size businesses. He holds a bachelors degree in ‘Internet Science’, is a member of 'Digital Analytics Association', a Google Analytics Certified Individual and a Certified Web Analyst. He is also the founder of EventEducation.com and EventPlanningForum.net.

My business thrives on referrals, so I really appreciate recommendations to people who would benefit from my help. Please feel free to endorse/forward my LinkedIn Profile to your clients, colleagues, friends and others you feel would benefit from SEO, PPC or Web Analytics.

 

 

  • Gregg Leventhal

    This information was exactly what I was looking for, thanks!

    • seohimanshu

      Glad you find the post useful. Thanks for stopping by.

  • Shankar Prabhu

    Great post! Is User ID, that would allow using a customer identifier that can be used for measurement across devices, available yet in Universal Analytics?

  • Daniel

    As a digital marketing with limited knowledge in development, I found this nearly impossible to follow.. :|

  • D’Anne

    Thank you! Thank you! Finally, someone who breaks Google Analytics information down and explains why to do what has to be done. I just can’t learn it without the “why”!! :)

    • seotakeaways

      Thank you for stopping by the blog.