Measurement Protocol Google Analytics分析发布请求未注册页面浏览量

问题描述

我正在尝试使用source注册mediumGoogle 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

解决方法

如果启用了视图中的漫游器筛选,则可能不会记录该匹配。这是因为使用Measurement Protocol数据协议看起来很像是一种将数据注入到您的媒体资源中的机器人。

尝试在“查看”设置中禁用此复选框:

enter image description here

,

调试端点vs收集端点

Debug endpoint仅用于验证匹配

https://www.google-analytics.com/debug/collect

本文档介绍了如何验证Google Analytics(分析)Measurement Protocol匹配。

debug终结点实际上并未将匹配发送给Google Analytics(分析)。如果您要在Google Analytics(分析)中注册数据,则应将其发送到

https://www.google-analytics.com/collect

一旦您更改了端点,则应检查实时报告以确保已收到匹配。如果没有,请确保该帐户已禁用漫游器过滤。

由于处理延迟,需要等待24-48小时才能在标准报告中查看数据。

将数据发布到正文中

除此之外,数据还应作为发布数据发送到您的请求正文中。

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);

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...