This is a really cool feature for Google Analytics data collection, of which I’ve heard very, very little buzz. It’s a way to debug any and all hits sent to the Google Analytics endpoint at
In all simplicity, you just need to copy the entire URL of the HTTP request to your clipboard, paste it into a web browser, and add
/debug between the hostname and
A few words on the Measurement Protocol
Let’s take a quick step back and remind ourselves of one important thing. Every single time you’re sending a hit to Google Analytics, whether it be via mobile app SDKs, analytics.js on your website, or by using arbitrary HTTP requests, you’re using the “Measurement Protocol". In other words, MP is not a discrete, isolated method of data transfer, but rather the underlying protocol that all the SDKs and libraries use as the method of dispatching payload data to GA.
So, when you hear a discussion along the lines of:
JANE: Let’s just configure the
ga('send'...) commands on the page to incorporate that feature.
JACK: Nah, let’s use Measurement Protocol instead.
They’re actually talking about the same thing. However, what Jack is probably referring to is a manually built HTTP request to the
/collect endpoint, using any of the zillions of different ways to do so. When you use the
ga('send'...) syntax, you’re communicating with the analytics.js library, and abstracting the HTTP request build process with a simplified shorthand syntax.
You can verify this by browsing to a Universal-Analytics-enabled website, opening the browser’s debugging tools, and looking at the network requests the site is sending:
Why is this significant? Why am I quibbling on semantics? Well, for one, I love to nitpick. But also, especially with the whole phenomenon of referral spam, people have been condemning Measurement Protocol as it introduces an open, unauthenticated venue for spamming a Google Analytics reporting profile.
Well, the reason it’s open and unauthenticated is because your website relies on the same protocol. If you were to add a layer of authentication there, it would need to happen server-side, as a spammer would be able to just visit your site, copy the payload request, and spam it until the authentication expires. Also, authentication would add latency, and that would affect Real Time reporting as well as the time for data to enter your reports.
But I’m sidetracking. Let’s get back on topic.
Using the debugger
As I mentioned, this hasn’t really been advertised, for some odd reason, but it is there. In fact, there’s even a support page for this feature.
So let’s go back to the example of the browser’s developer tool, and inspecting the network request to
/collect. Copy the entire request URL (in Chrome it’s right-click => Copy Link Address on the request), and paste it into a new browser window.
If you now press Enter, your browser will simply send the request to GA. However, before you press Enter, add /debug into the URL, between the hostname and
/collect, so it looks like this:
And now press Enter. You should see the response in your web browser:
Since you’re copying a request sent by your website, you should hope it’s valid. If it isn’t, start working on a fix!
Why it’s useful
Well, for one, you can debug your hits and see if there’s something wrong with them. Common mistakes include when you’ve got a field value wrong in your code, or when you’ve forgotten to add a field which is required. For example, setting Event Value to a blank string or a decimal number would return an error, as if the field is in the request, it always needs to be an integer.
Another good use case is for when you’re actually using the Measurement Protocol in your custom setups. The debugger returns a response object, meaning you can debug your setup without actually sending data to Google Analytics! By parsing the response, you can easily identify if your custom payload is working or not.
I know I’m in the geek camp with this, but this feature is definitely packing a kiloton worth of awesome in a small space. This is a perfect way to test your setups without sending actual data to Google Analytics, and the response object has lots of information, all missing from the actual request to