关于 Google Analytics 跟踪的问题(带 Rails) [英] Question about Google Analytics Tracking (w/ Rails)

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

问题描述

我在 Rails 项目上设置了 Google Analytics,并且为跟踪选项选择了单个域(默认)".

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

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

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?

我问这个问题的原因是我们一直在使用 rspec 在我们的开发计算机上运行测试,并且分析似乎出现了峰值.所有这些高峰似乎也显示为唯一身份访问者.

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.

谢谢!

推荐答案

是的,它也跟踪本地访问.您可能应该使用 ruby​​ 条件语句将其排除在本地连接中.例如在布局文件的底部

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 %>

这样,如果从本地建立连接,则不会打印 Google Analytics.

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

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

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