google-analytics - Firefox版本> 56我可以实时查看流量,但无法在任何报告或仪表板中查看

标签 google-analytics

请找到我用来跟踪扩展程序dialog.html页面分析的javascript代码。

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-********-1']);
var ga = document.createElement('script'); 
ga.type = 'text/javascript'; 
ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; 
s.parentNode.insertBefore(ga, s);

var trackPage = function () {

let request = new XMLHttpRequest();

request.open("POST", "https://www.google-analytics.com/collect", true);

let message ="v=1&tid=" + "UA-**********-1" + "&cid= " + "*********" + "&aip=1" +"&ds=add-on&t=pageview&dp="+"dialog.html"+"&dt="+"TruePath-Home";

request.send(message);
}


function setDOMInfo() 
   {

    if (browser_version>55 && browser_name==='Firefox' ){
        trackPage();
    }
    else{
    _gaq.push(['_trackPageview']);
    }
   }


由于较新版本的Firefox不允许跟踪,因此我编写了用于跟踪的自定义代码。setDOMInfo函数在加载dialog.html时启动。

我观察到,对于> 56的Firefox版本,我可以实时查看流量,但看不到任何报告或仪表板。

最佳答案

最后,我能够弄清楚为什么它不更新Firefox版本> 56的分析。

我们需要将userAgent信息与请求一起传递。检索userAgent的javascript代码,如下所示:
var data = navigator.userAgent;

所以你的代码是

var trackPage = function () {
let request = new XMLHttpRequest();
var data = navigator.userAgent;
request.open("POST", "https://www.google-analytics.com/collect", true);
let message ="v=1&tid=" + "UA-**********-1" + "&cid= " + "*********" + "&aip=1" +"&ds=add-on&t=pageview&dp="+"dialog.html"+"&dt="+"TruePath-Home"+"&ua="+data;

request.send(message);


}

关于google-analytics - Firefox版本> 56我可以实时查看流量,但无法在任何报告或仪表板中查看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51594117/

相关文章:

google-analytics - 对多个帐户的Google Analytics(分析)事件跟踪不起作用

iOS 应用程序在加载 GoogleTagManager 容器时崩溃

php - 谷歌分析 PHP API : Get event total events

google-analytics - 试图将 http ://www. example.com 链接到我在 https ://secure. example.com 上的购物车

python - 如何在Google Analytics API中调用辅助维度

google-analytics - 跟踪 Analytics 客户 ID 和 Adwords 点击 ID

apache - 谷歌分析 : subdomains and Apache's basic auth

google-analytics - 谷歌分析增强电子商务问题

google-analytics - 查询 session 上的自定义维度和点击级别

google-analytics - 从 GA 迁移到 GTM - 需要哪些跟踪代码?