Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 谷歌分析与rails 4不发送数据_Ruby On Rails_Ruby_Google Analytics - Fatal编程技术网

Ruby on rails 谷歌分析与rails 4不发送数据

Ruby on rails 谷歌分析与rails 4不发送数据,ruby-on-rails,ruby,google-analytics,Ruby On Rails,Ruby,Google Analytics,我已经尝试过使用一个partial和google analytics rails gem来包含google analytics,但是我没有得到任何结果。当我登录到我的帐户时,它说它正在从域接收数据,这是非常不可能的,因为它在代码实际推送到生产服务器之前就这样说了 第一次尝试 layouts/_google_analytics.html.erb <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['

我已经尝试过使用一个partial和google analytics rails gem来包含google analytics,但是我没有得到任何结果。当我登录到我的帐户时,它说它正在从域接收数据,这是非常不可能的,因为它在代码实际推送到生产服务器之前就这样说了

第一次尝试

layouts/_google_analytics.html.erb

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'Figs.third_party_keys.google.analytics']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
这没有给出任何结果,因此我转而使用谷歌分析rails gem。我安装了gem和ran包,然后在我的production.rb中添加了以下行:

GA.tracker = "UA-xxxxxx-x" (I tried this with and without Figgy)
感觉这两项都是非常简单的任务,但没有得到我想要的结果。可能是因为试图使用Figgy。

这一行:

_gaq.push(['_setAccount', 'Figs.third_party_keys.google.analytics']);
对我来说是可疑的。您正在将_setAccount设置为文字字符串“Figs.third_party_keys.google.analytics”。这应该是:

_gaq.push(['_setAccount', <%= Figs.third_party_keys.google.analytics %>]);
?

_gaq.push(['_setAccount', <%= Figs.third_party_keys.google.analytics %>]);