Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




How to use Measurement Protocol to send hits to Google Analytics

What is Measurement Protocol and how to send hits to Google Analytics

With all these privacy related changes, first party information is more important than ever. To get ahead of the changes you must build or enhance your existing analytics information as much as possible.

If you work closely with Google Analytics, you’ll know that there are many cases where you have to track offline information. Searching about the ways to do it, you are probably reading about Measurement Protocol again and again. This might be the most frightening word (after data sampling) as when I talk to someone about Measurement Protocol, I often see the look of pure fear in their faces.

In this post, I will try to remove this look and describe a little bit what Measurement Protocol is, how can be used, its limitations and some workarounds I did over the years hoping to help anyone who hasn’t got their hands dirty yet.

This will not be a deep technical guide, rather than a business-wise overview to help you have an understanding of what this method of sending data can do and if it could help you with your business use case along with some resources to dive deeper if preferred.

If you are not already familiar with Measurement Protocol, let me start by explaining a little bit of what it is. The Google Analytics Measurement Protocol is an API endpoint that allows developers and businesses to send data directly to Google Analytics servers.

This can be done by using HTTP request and it’s really useful as there are many cases where you need to measure how users interact with your business from almost any environment and without requiring a user to perform an action specifically to your website. Such cases can be:

Of course, Measurement Protocol is not there to completely replace Google Analytics. Even though there are many things that you can do with, it works best when used along with online tracking capabilities of Google Analytics.

Google Analytics 4 (GA4) is the new version of Google Analytics that helps you track web and mobile traffic efficiently. GA4 is continuously updated by Google and lately, the support for Measurement Protocol hits was introduced.

This post is mainly focused on Universal Analytics installations as the API for GA4 is currently in alpha version and it may change significantly in the future. That being said, implementing a system that sends important information directly to Google Analytics via Measurement Protocol hits is still and will be relevant and based on our experience, things won’t change so much that it will be impossible to migrate the existing setup to support Google Analytics 4 properties.

Enough with what you can and cannot do with Measurement Protocol. Let’s jump into action. Before setting up your flow or send a hit manually, you have to check that your hit is valid. By valid, I mean that the hit can be properly read by Google Analytics and if you send it, it will be integrated with the rest of your data.

When you first visit Hit Builder and before start using the tool, you have to be authenticated. You will be introduced to the below status:

Hit Builder authorization

Click on “Click here to authorize” button and follow the standard Google authorization process. After the successful authorization process, you are ready to use the tool and start building your hits.

In the “Hit Parameter Details” section you can add as many parameters you want with their respective values:

Moreover, for certain type of hits some more parameters are also required. For example for “pageview” hits, either “dl” or both “dh and “dp have to be specified for the hit to be valid.

After you have built your Measurement Protocol hit with all the values, it’s time to validate it and see if it would be registered to Google Analytics. To validate your hit, you can click “Validate Hit” option in the panel:

If your hit is properly built and formatted, then you will see the below screen:

That indicates a successful validation process and you can:

If your hit is not valid, you will see the below screen that indicates that the hit was not validated along with some hints on what’s missing:

In this case, as we’re trying to send a “pageview” hit, we are seeing that “cid” and “tid” required parameters are missing. You can proceed with the fixes and hit “Revalidate hit” to try the validation process again.

So we’ve seen what Measurement Protocol is, how to build a hit and how to validate and ensure that the hit will be properly registered in Google Analytics Servers. Now let’s try some examples and some of the most common use cases of Measurement Protocol hits.

One of the most common use case for Measurement Protocol hits is if we want to send offline purchases (e.g. sales via phone center) to Google Analytics in order to have an overview of our business performance.

A purchase order in Google Analytics is a set of two things:

That’s what we’re going to build here. We’ll send a pageview hit to Google Analytics that contains a transaction and two products. Let’s see that in action:

This is an example of a pageview hit with transaction information. Let’s try to decompose it and see what the parameters are:

With the above hit, we sent a transaction to Google Analytics (with the id: 00001D) with total value of 1001.00€ that had three products within (1x iPhone XR & 2x Apple Airpods Pro).

Another common and great use case is to send Refunds back to Google Analytics. If you want to have as accurate data as possible in Google Analytics, it’s important to track transaction refunds. Refunds are used in order to have a better overview of the actual revenue and optimize your business accorndigly. A “Refund” hit looks like the below:

This is an example of an event hit with the refund information. Let’s try to decompose it and see what the parameters are:

Offline conversions are not limited to transactions. Conversions might be defined as calls to call center, account approvals and many more. All these conversions can be tracked via standard events. To track a standard event you can build a hit like the below:

This is an example of an event hit with the refund information. Let’s try to decompose it and see what the parameters are:

After you send the above, you can define this custom event (Account — Approval) as a Goal and track the account approvals as conversions.

In this short post you learned what Measurement Protocol is, how it can be beneficial to your business and how to properly set up & validate your hits. Moreover, you have seen three of the most common examples to track offline information to Google Analytics along with some important hits.

I hope that after you read the above, Measurement protocol is no longer a terrifying word and you feel ready to start tracking important information to your business.

Add a comment

Related posts:

Motion Designer Peter Steineck Compress Emotions into Colorful Compositions

Motion designer and illustrator Peter Steineck creates immersive compositions using colors and patterns. The viewer can quickly notice that Steineck creates his works in another world. He carries the…

The Cryptocurrency of Choice By Traders for Traders

Should Traders be compensated for Execution-(Anyway the brokers takes a lot in commission in every trade)? Should Traders be compensated Profit or Lesson learnt-(it takes beyond a will power to…

Why NASA Abandoned the Gemini Rogallo Wing

Splashdowns are iconic of the Apollo era. From the first suborbital Mercury flight, the image of a capsule hitting the water became synonymous with the triumphant end of a mission. But even though…