首页 > 解决方案 > 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

标签: javascriptgoogle-analyticsmeasurement-protocol

解决方案


If bot filtering in your view is enabled the hit may not be recorded. This is because using the Measurement protocol data protocol looks a lot like a bot injecting data into your property.

Try to disable this checkbox in your View settings:

enter image description here


推荐阅读