【问题标题】:Ecommerce tracking google analytics电子商务跟踪谷歌分析
【发布时间】:2020-06-14 06:16:40
【问题描述】:

您好,我正在尝试使用 analytics.js 发送数据,但显示错误。

<head>
  <meta charset="utf-8">
  <title>GanalaticsDemo</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>

<form action="">
  <label for="gsearch">Search Google:</label>
  <input type="search" id="gsearch" name="gsearch">
  <input type="submit">
</form>


<script>

(function(i, s, o, g, r, a, m) {
   i['GoogleAnalyticsObject'] = r;
    i[r] = i[r] || function() {
        (i[r].q = i[r].q || []).push(arguments)
    }, i[r].l = 1 * new Date();
    a = s.createElement(o),
        m = s.getElementsByTagName(o)[0];
    a.async = 1;
    a.src = g;
    m.parentNode.insertBefore(a, m)
    //})(window, document, 'script', 'https://www.google-analytics.com/analytics_debug.js', 'ga');
      })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
    var _gaq = _gaq || [];

_gaq.push(["_setAccount", "UA-169197862-1"]);
_gaq.push(["_setDomainName", "none"]);
_gaq.push(["_trackPageview"]);
// window.ga_debug = {trace: true}; 

ga('create', 'UA-169197862-1', 'auto');// add your tracking ID here.

ga('require','ecommerce','ecommerce.js')
ga('ecommerce:addTransaction',{

    'id':'1234',//Transaction id 
    'affiliation':'skinny jeans',
    'revenue':'28.8',
    'shipping':'10.00',
    'tax':'1.89'
});

ga('ecommerce:addItem',{

    'id':'1234',
    'name':'OKEJeans',
    'sku':'SKJ49',
    'category':'Men Jeans',
    'price':'76.65',
    'quantity':'1'
});
ga('ecommerce.send')
ga('send', 'pageview');


</script>
<a href="http://www.example.com/products/detail/product-1.html#contactsales" onclick="ga('send', 'event', 'Contact Sales', 'click');">Contact Sales</a>

</body>

开发者工具报错:运行命令:ga("ecommerce.send");

analytics_debug.js:25 命令被忽略。未知目标:未定义和正在运行的命令:ga("send", "pageview") analytics_debug.js:25 不允许的文档协议。中止命中。

我在互联网上搜索,但很多人说要添加目标名称,但它也不起作用。

【问题讨论】:

    标签: google-analytics


    【解决方案1】:

    您正在混合 _ga 和 _gaq 代码库。第二个库已弃用。

    【讨论】:

    • Michele 请详细说明我必须编写什么代码来代替它才能使其正常工作。
    猜你喜欢
    • 1970-01-01
    • 2014-04-14
    • 2012-11-14
    • 2011-01-24
    • 2015-03-27
    • 1970-01-01
    • 2013-09-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多