javascript - Measurement Protocol Google Analytics Post 请求未注册页面浏览量
问题描述
我正在尝试使用Google Analytics Measurement Protocol注册来源和媒介印象。
我没有看到 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/返回“命中有效!”
如果我将请求发送到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
任何人都可以解释为什么我没有看到页面浏览量和源/媒体被记录。
谢谢!
-cwmacken
解决方案
推荐阅读
- javascript - 如何在按回车键使用 contenteditable 时多次提交表单
- java - 这段代码的问题在于输出。生产者生产不止一次。为什么以及如何解决它?
- scala - Scala:有没有一种方法可以将类型别名与它们别名的类型区别对待?
- c# - Unity - SendMessage,但用于变量而不是函数/方法
- wpf - Telerik RadMenuItem IsEnabled 没有持续刷新
- f# - 删除 F# 中嵌套列表中的第一个元素?
- python - 如何使用按钮将图像一张一张地添加到网格的每个单元格中
- java - 垂直直方图
- javascript - 如何注册一个 ServiceWorker 回来
- python-3.x - 我无法在我的 Mac 上的 python3 中导入熊猫