Universal Analytics Measurement Protocol respond 200 OK, but no events appers

别说谁变了你拦得住时间么 提交于 2020-01-02 01:04:29

问题


I am sending events from Winform application to Universal Analytics via Measurement protocol and I use fiddler to inspect the request and response. Everything seems to be OK, but no events appears in Universal Analytics.

My app request:

POST http://www.google-analytics.com/collect HTTP/1.1
Host: www.google-analytics.com
Content-Length: 112
Expect: 100-continue

v=1
&tid=UA-44974825-1
&cid=1aba0888-732f-4690-9a91-d906c94a4a23
&t=exception
&exd=NullReferenceException
&exf=1

Server response:

HTTP/1.1 200 OK
Pragma: no-cache
Expires: Mon, 07 Aug 1995 23:30:00 GMT
Cache-Control: private, no-cache, no-cache=Set-Cookie, proxy-revalidate
Access-Control-Allow-Origin: *
Last-Modified: Sun, 17 May 1998 03:00:00 GMT
X-Content-Type-Options: nosniff
Content-Type: image/gif
Date: Fri, 18 Oct 2013 13:54:39 GMT
Server: Golfe2
Content-Length: 35
Alternate-Protocol: 80:quic

GIF89a�����������,�������D�;

回答1:


Your request is missing the app name parameter, &an, which is required for sending data to app profiles in Google Analytics via the Measurement Protocol.

The requirements for sending app data to Google Analytics via the Measurement Protocol are documented here: https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#apptracking

The GA endpoint will always return 200, even if the request is missing required parameters.




回答2:


I discovered another reason why no data is being collected: I hadn't upgraded my property to Universal Analytics, yet! Doh!




回答3:


The root problem here is that you are not formatting your request properly. You need to format your POST body like any other application/x-www-form-urlencoded encoded POST body, all on one line:

v=1&tid=UA-44974825-1&cid=1aba0888-732f-4690-9a91-d906c94a4a23&t=exception&exd=NullReferenceException&exf=1



回答4:


For anyone who lands here looking for solution to something similar, check this tool: Hit builder to validate the payload data. I was facing the same issue this tool helped.

(Not sure if this debug tool was available then when this question was posted)



来源:https://stackoverflow.com/questions/19451738/universal-analytics-measurement-protocol-respond-200-ok-but-no-events-appers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!