有关Google Analytics(分析)跟踪(w / Rails)的问题 [英] Question about Google Analytics Tracking (w/ Rails)

查看:91
本文介绍了有关Google Analytics(分析)跟踪(w / Rails)的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在rails项目上设置了google analytics设置,并且我为跟踪选项选择了单个域(默认)。



我已将此js代码复制并粘贴到应用程序的布局中。

现在,如果我在本地使用它,分析是否也跟踪本地使用情况?



我问这个问题的原因是,我们一直在使用rspec在我们的开发计算机上运行测试,并且分析似乎有一个尖峰。所有这些高峰似乎都显示为独特的访客。



我很感激这方面的任何见解。



感谢!

解决方案

是的,它也会跟踪本地访问。
您应该使用ruby条件语句将其排除在本地连接器之外。
例如,在布局文件的底部

 <%if!request.local? %GT; 
您Google Analytics(分析)的源代码
<%end%>

这样,如果从本地连接,Google Analytics(分析)将不会被打印。

b $ b

I've got google analytics setup on a rails project, and I've got "A single domain (default)" selected for the tracking options.

I've copied and pasted the js code into the layout for the application.

Now, if I use this locally, does analytics track the local use as well?

The reason I'm asking this is we've been running tests on our dev computers using rspec, and there seems to be a spike in the analytics. All these spikes also seem to show up as unique visitors.

I'd appreciate any insight on this.

Thanks!

解决方案

Yes, it does track local visits as well. You should probably use ruby conditional statement to exclude it for the local conneciton. For example, at the bottom of the layout file

<% if !request.local? %>
Your source codes for Google Analytics
<% end %>

This way, Google Analytics will not be printed if connection is made from local.

这篇关于有关Google Analytics(分析)跟踪(w / Rails)的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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