Measurement Protocol Google Analytics Post 请求未注册页面浏览量
Measurement Protocol Google Analytics Post request not registering page views
我正在尝试注册 source and medium impressions using the Google Analytics Measurement Protocol。
我没有看到综合浏览量或 source/mediums 被记录在 GA 仪表板中。
我 运行 这个片段在我的 head 标签中。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
var randomid = Math.floor(Math.random() * 1000000);
var path = window.location.pathname;
var pathuri = encodeURIComponent(window.location.pathname)
var url = 'https://www.google-analytics.com/collect?v=1&tid=UA-XXXXXXXX-X&cid='+randomid+'&t=pageview&cs=tvstest3&cm=ctvtest3&dp='+pathuri;
$.post(url, function(data, status){
console.log("Data: " + data + "\nStatus: " + status);
});
</script>
这导致网络调用
https://www.google-analytics.com/collect?v=1&tid=UA-XXXXXX-X&cid=537396&t=pageview&cs=tvstest3&cm=ctvtest3&dp=%2Ftest3.html
https://ga-dev-tools.appspot.com/hit-builder/ returns“命中有效!”
如果我将请求发送到 https://www.google-analytics.com/debug/collect
Data: {
"hitParsingResult": [ {
"valid": true,
"parserMessage": [ ],
"hit": "/debug/collect?v=1\u0026tid=UA-XXXXXXX-X\u0026cid=521292\u0026t=pageview\u0026cs=tvstest3\u0026cm=ctvtest3\u0026dp=%2Ftest3.html"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
}
Status: success
谁能解释一下为什么我没有看到综合浏览量并且 source/medium 被记录了。
谢谢!
-cwmacken
调试端点与收集端点
Debug endpoint 仅用于验证命中
https://www.google-analytics.com/debug/collect
This document describes how to validate Google Analytics Measurement Protocol hits.
调试端点实际上不会将命中发送到 google 分析。如果您想要在 google analytics 中注册的数据,您应该将其发送至
https://www.google-analytics.com/collect
更改端点后,您应该检查实时报告以确保已收到命中。如果不确定,请确保已在帐户上禁用机器人过滤。
由于处理延迟,需要等待 24 - 48 小时才能看到标准报告中的数据。
Post 正文中的数据
超出数据应作为 post 数据在您的请求正文中发送。
POST /collect HTTP/1.1
Host: www.google-analytics.com
v=1&tid=UA-XXXXXXXX-X&cid='+randomid+'&t=pageview&cs=tvstest3&cm=ctvtest3&dp='+pathuri
代码
我不是 JavaScript 开发者,但我认为你应该看看这样的东西。
var http = new XMLHttpRequest();
var url = 'https://www.google-analytics.com/collect';
var params = 'v=1&tid=UA-XXXXXXXX-X&cid='+randomid+'&t=pageview&cs=tvstest3&cm=ctvtest3&dp='+pathuri';
http.open('POST', url, true);
//Send the proper header information along with the request
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(params);
如果在您的视图中启用了机器人过滤,则可能不会记录命中。这是因为使用 Measurement protocol 数据协议看起来很像机器人将数据注入您的 属性.
尝试在您的视图设置中禁用此复选框:
我正在尝试注册 source and medium impressions using the Google Analytics Measurement Protocol。
我没有看到综合浏览量或 source/mediums 被记录在 GA 仪表板中。
我 运行 这个片段在我的 head 标签中。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
var randomid = Math.floor(Math.random() * 1000000);
var path = window.location.pathname;
var pathuri = encodeURIComponent(window.location.pathname)
var url = 'https://www.google-analytics.com/collect?v=1&tid=UA-XXXXXXXX-X&cid='+randomid+'&t=pageview&cs=tvstest3&cm=ctvtest3&dp='+pathuri;
$.post(url, function(data, status){
console.log("Data: " + data + "\nStatus: " + status);
});
</script>
这导致网络调用
https://www.google-analytics.com/collect?v=1&tid=UA-XXXXXX-X&cid=537396&t=pageview&cs=tvstest3&cm=ctvtest3&dp=%2Ftest3.html
https://ga-dev-tools.appspot.com/hit-builder/ returns“命中有效!”
如果我将请求发送到 https://www.google-analytics.com/debug/collect
Data: {
"hitParsingResult": [ {
"valid": true,
"parserMessage": [ ],
"hit": "/debug/collect?v=1\u0026tid=UA-XXXXXXX-X\u0026cid=521292\u0026t=pageview\u0026cs=tvstest3\u0026cm=ctvtest3\u0026dp=%2Ftest3.html"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
}
Status: success
谁能解释一下为什么我没有看到综合浏览量并且 source/medium 被记录了。
谢谢!
-cwmacken
调试端点与收集端点
Debug endpoint 仅用于验证命中
https://www.google-analytics.com/debug/collect
This document describes how to validate Google Analytics Measurement Protocol hits.
调试端点实际上不会将命中发送到 google 分析。如果您想要在 google analytics 中注册的数据,您应该将其发送至
https://www.google-analytics.com/collect
更改端点后,您应该检查实时报告以确保已收到命中。如果不确定,请确保已在帐户上禁用机器人过滤。
由于处理延迟,需要等待 24 - 48 小时才能看到标准报告中的数据。
Post 正文中的数据
超出数据应作为 post 数据在您的请求正文中发送。
POST /collect HTTP/1.1
Host: www.google-analytics.com
v=1&tid=UA-XXXXXXXX-X&cid='+randomid+'&t=pageview&cs=tvstest3&cm=ctvtest3&dp='+pathuri
代码
我不是 JavaScript 开发者,但我认为你应该看看这样的东西。
var http = new XMLHttpRequest();
var url = 'https://www.google-analytics.com/collect';
var params = 'v=1&tid=UA-XXXXXXXX-X&cid='+randomid+'&t=pageview&cs=tvstest3&cm=ctvtest3&dp='+pathuri';
http.open('POST', url, true);
//Send the proper header information along with the request
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(params);
如果在您的视图中启用了机器人过滤,则可能不会记录命中。这是因为使用 Measurement protocol 数据协议看起来很像机器人将数据注入您的 属性.
尝试在您的视图设置中禁用此复选框: