Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics Measurement Protocol not working

I want to track an application that runs in different environments:

  • phonegap build
  • node-webkit app
  • website

In order to use one tracking mechanism for all I thought it would be a good idea to use the "Measurement Protocol"

I set up a new tracking property (type Website) and performed multiple requests to the www.google-analytics.com/collect site as described in their devguide. I always get the Status 200 (OK) from my POST request, but unfortunately I can´t see any tracking information coming in to my GA account.

Here is what the request looks like (Build with Postman plugin for Chrome):

POST /collect?v=1&tid=UA-29xxxxxx-2&cid=35009a79-1a05-49d7-b876-2b884d0f825b&t=pageview&dh=mysite.com&dp=%2Fhome&dt=Homepage&an=myapp HTTP/1.1
Host: www.google-analytics.com
Cache-Control: no-cache

Basically I´m sending these parameters:

v=1
&tid=UA-29xxxxxx-2
&cid=35009a79-1a05-49d7-b876-2b884d0f825b
&t=pageview
&dh=mysite.com
&dp=%2Fhome
&dt=Homepage
&an=myapp

I also tried to create a "Mobile Application" in Google Analytics and use that tracking id instead. Same result here - no tracking information in Google Analytics.

Does anyone know, how to perform this tracking requests successfully or if there is a debug-option so that I can at least see, why the tracking call is not saved? Thanks!

like image 615
tomraithel Avatar asked Dec 08 '14 12:12

tomraithel


People also ask

What is Google Analytics measurement protocol?

The Google Analytics Measurement Protocol allows developers to make HTTP requests to send raw user interaction data directly to Google Analytics servers. This allows developers to measure how users interact with their business from almost any environment.

Can I use both Google Analytics 4 and Universal Analytics?

By dual tagging you can keep your Universal Analytics implementation in place while you build out your Google Analytics 4 implementation.

How do I know if Google Analytics 4 is working?

To see if Google Analytics is firing on your page, go to any page on your site in your Chrome Browser and right-click. Click on Inspect. Then go to the Network tab. Hit refresh on your browser and watch to see the different content and scripts loading on the page.


1 Answers

Had the same problem: whatever I POSTed, it did not show up in GA. Debug API successfully validated my hits. Finally, I found out what was missing: you must send a user agent string (parameter ua), too.

like image 100
SomeGuest Avatar answered Sep 24 '22 07:09

SomeGuest