google 测量协议给出奇怪的响应
google Measurement Protocol giving weird response
我正在尝试使用 php7 进行设置,然后大口大口地休息 API。当我在 curl 中使用 cli 将请求发送到调试 url 我得到一个很好的 json 响应
{
"hitParsingResult": [ {
"valid": true,
"parserMessage": [ ],
"hit": "/debug/collect?v=1\u0026t=pageview\u0026tid=UA-1234567-1\u0026uid=UA-1234567-1\u0026dh=test.domain.com\u0026dp=/api/user/verify/flow"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
}
但是如果我把它发送给产品 url 我每次都会收到奇怪的回复
GIF89a▒▒▒▒▒,D;
有人知道怎么解决吗?
这就是我在 cli运行 上的内容
curl -X POST -d 'v=1&t=pageview&tid=UA-xxxxxxxxx-1&uid=UA-xxxxxxxxx-1&dh=test.domain.com&dp=%2Fiwsapi%2Fuser%2Fverify%2Fflow' https://www.google-analytics.com/debug/collect
对于非调试模式,我只是删除了调试
curl -X POST -d 'v=1&t=pageview&tid=UA-xxxxxxxxx-1&uid=UA-xxxxxxxxx-1&dh=test.domain.com&dp=%2Fiwsapi%2Fuser%2Fverify%2Fflow' https://www.google-analytics.com/collect
我正在大口大口地建造它
$promise = $guzzle->post("/debug/collect", [
'proxy' => [
'http' => 'http://proxy:8080',
'https' => 'http://proxy:8080',
],
'form_params'=>[
'v'=>1,
't'=>'pageview',
'tid'=>GOOGLE_ID,
'uid'=>$_SERVER['HTTP_CTVFNTUSERNAME'],
'dh'=>WWWHOST,
'dp'=>$_SERVER['REQUEST_URI'],
//'dt'=>'homepage'
]
]);
The Measurement Protocol will return a 2xx status code if the HTTP request was received. The Measurement Protocol does not return an error code if the payload data was malformed, or if the data in the payload was incorrect or was not processed by Google Analytics.
If you do not get a 2xx status code, you should NOT retry the request. Instead, you should stop and correct any errors in your HTTP request.
无论如何,测量协议实际上并不会验证您的命中,您将获得的唯一响应是 GIF89a▒▒▒▒▒,D
;
的 1x1 像素图像
所以真的没有什么可以解决它应该正常工作的问题。唯一会向您发送正确响应的是您似乎正在使用的调试端点
您需要在请求中添加 User-Agent header。
进一步的解释在这里:
https://groups.google.com/g/google-analytics-measurement-protocol/c/VVaoSU-2FB4?pli=1
我正在尝试使用 php7 进行设置,然后大口大口地休息 API。当我在 curl 中使用 cli 将请求发送到调试 url 我得到一个很好的 json 响应
{
"hitParsingResult": [ {
"valid": true,
"parserMessage": [ ],
"hit": "/debug/collect?v=1\u0026t=pageview\u0026tid=UA-1234567-1\u0026uid=UA-1234567-1\u0026dh=test.domain.com\u0026dp=/api/user/verify/flow"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
}
但是如果我把它发送给产品 url 我每次都会收到奇怪的回复
GIF89a▒▒▒▒▒,D;
有人知道怎么解决吗?
这就是我在 cli运行 上的内容
curl -X POST -d 'v=1&t=pageview&tid=UA-xxxxxxxxx-1&uid=UA-xxxxxxxxx-1&dh=test.domain.com&dp=%2Fiwsapi%2Fuser%2Fverify%2Fflow' https://www.google-analytics.com/debug/collect
对于非调试模式,我只是删除了调试
curl -X POST -d 'v=1&t=pageview&tid=UA-xxxxxxxxx-1&uid=UA-xxxxxxxxx-1&dh=test.domain.com&dp=%2Fiwsapi%2Fuser%2Fverify%2Fflow' https://www.google-analytics.com/collect
我正在大口大口地建造它
$promise = $guzzle->post("/debug/collect", [
'proxy' => [
'http' => 'http://proxy:8080',
'https' => 'http://proxy:8080',
],
'form_params'=>[
'v'=>1,
't'=>'pageview',
'tid'=>GOOGLE_ID,
'uid'=>$_SERVER['HTTP_CTVFNTUSERNAME'],
'dh'=>WWWHOST,
'dp'=>$_SERVER['REQUEST_URI'],
//'dt'=>'homepage'
]
]);
The Measurement Protocol will return a 2xx status code if the HTTP request was received. The Measurement Protocol does not return an error code if the payload data was malformed, or if the data in the payload was incorrect or was not processed by Google Analytics.
If you do not get a 2xx status code, you should NOT retry the request. Instead, you should stop and correct any errors in your HTTP request.
无论如何,测量协议实际上并不会验证您的命中,您将获得的唯一响应是 GIF89a▒▒▒▒▒,D
;
所以真的没有什么可以解决它应该正常工作的问题。唯一会向您发送正确响应的是您似乎正在使用的调试端点
您需要在请求中添加 User-Agent header。 进一步的解释在这里: https://groups.google.com/g/google-analytics-measurement-protocol/c/VVaoSU-2FB4?pli=1