在本地主机上运行谷歌Analytics(分析) - 错误加载插件 [英] Running Google Analytics on localhost - error loading the plugin

查看:191
本文介绍了在本地主机上运行谷歌Analytics(分析) - 错误加载插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从将数据发送到谷歌分析HTML文件执行该code。在code本身是在本地主机上的文件,我在浏览器中打开它。因此,这不是在网络服务器。

I have this code to be executed from an html file which sends data to Google Analytics. The code itself is in a file on the localhost and I'm opening it in a browser. So it's not on the webserver.

<html>
  <head>
  <script>
  alert('hello123');
  (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','http://www.google-analytics.com/analytics.js','ga');


  ga('create', 'UA-xxxxxx-1', 'none');
  ga('set', 'checkProtocolTask', null); 
  ga('send', 'pageview');

  // ga('require', 'ecommerce');
  ga('require', 'ecommerce', 'ecommerce.js');

  /*ecommerce*/
  ga('ecommerce:addTransaction', {
  'id': 'storeId123_test_cartId123_test_1426000599',
  'affiliation': '',
  'revenue': '352429',
  'shipping': '334433',
  'tax': '3344'
});

  ga('ecommerce:addItem', {
  'id': 'storeId123_test_cartId123_test_1426000599',
  'name': 'title_123',
  'sku': 'sku_123',
  'category': 'some_category',
  'price': '444',
  'quantity': '33'
});

  ga('ecommerce:send',{'hitCallback': function() {alert("ecommerce");}});

</script>
</head>
<body>

</body>
</html>

我有错误:

1)插件电子商务错误加载资源:拒绝加载URL:的 http://www.google-analytics.com/plugins/ua/ecommerce.js

1) Error loading resource for plugin "ecommerce": Refusing to load url: "http://www.google-analytics.com/plugins/ua/ecommerce.js"

虽然该网址是avaible。

although that url is avaible.

2)存储设备不可用。中止命中 - 但我在嘎'无'('创造','UA-XXXXXX-1','无');

2) Storage not available. Aborting hit -- but I have 'none' in ga('create', 'UA-xxxxxx-1', 'none');

主要错误是第一位的,我相信第二个是有关的。

The main error is the first one, I believe the 2nd is related to it.

推荐答案

似乎Cookie域none和电子商务,插件的组合不起作用。我没有钻研够深到跟踪code,找出为什么会是这样,我只是测试它 - 当我保存code在文件中的位置是在Web服务器上的电子商务跟踪失败与无和作品有自动。

It seems that the combination of cookie domain "none" and the ecommerce-plugin does not work. I haven't delved deeply enough into the tracking code to find out why this is so, I have simply tested it - when I save your code in a file an place it on a web server the ecommerce tracking fails with "none" and works with "auto".

这意味着,如果你想测试电子商务跟踪code你不能从文件系统这样做。我建议你​​设置一个本地网络服务器(我喜欢[XAMPP],其中 1 包括阿帕奇,MySQL和PHP和运行在Windows和Mac),并从那里测试code。

This means if you want to test E-Commerce Tracking Code you cannot do so from the filesystem. I would recommend you set up a local webserver (I like [XAMPP], which1 includes apache, mysql and php and runs on Windows and Mac) and test your code from there.

这篇关于在本地主机上运行谷歌Analytics(分析) - 错误加载插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆