5

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!

tomraithel
  • 958
  • 2
  • 13
  • 22

2 Answers2

19

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.

SomeGuest
  • 191
  • 1
  • 3
3

Cross reference to other given solutions: How to correctly use google analytics measurement protocol?

Takeaway:

  • use the /debug/collect endpoint
  • Check the GA live report after a try with /collect
  • Check you ua and cid parameters
  • Use proxying that browser extensions don't fish away your requests

My request now looks like: https://strongstaff.eu/statistics?v=1&tid=UA-XXX&cid=35009a79-1a05-49d7-b876-2b884d0f825b&t=pageview&dp=/&dt=Homepage&an=myapp%20HTTP/1.1&ua=Mmyapp%20HTTP/1.1

which proxy_pass'es to: proxy_pass https://www.google-analytics.com/collect?$args;

velop
  • 3,102
  • 1
  • 27
  • 30