• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

bgarret/google-analytics-rails: Rails 3 helpers to manage google analytics track ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

bgarret/google-analytics-rails

开源软件地址(OpenSource Url):

https://github.com/bgarret/google-analytics-rails

开源编程语言(OpenSource Language):

Ruby 100.0%

开源软件介绍(OpenSource Introduction):

Fast Universal Google Analytics setup for Rails. This gem is mostly intended for small to medium websites with a simple analytics strategy.

Build Status

For older analytics, please use 0.0.6_

Installation

Add the following to your Gemfile:

gem 'google-analytics-rails', '1.1.1'

Then run:

bundle install

Upgrade Notes

Upgrading this gem from 0.0.6?

Use analytics_init to send submissions to Analytics if you are using multiple trackers. You can supply a name to tracker by passing :name option.

GoogleAnalytics::Events::SetAllowLinker is no longer supported as an external variable being set. You can submit as normal in the :add_events array, but using the new :setup config is preferable so no extra array searching has to happen.

GoogleAnalytics::Events::SetCustomVar is no longer supported by Universal Analytics. These have been changed to SetCustomDimension & SetCustomMetric. By default if you use SetCustomVar, it applies as a Dimension

GoogleAnalytics::Events::DeleteCustomVar has been removed

Added Event Helpers

  • GoogleAnalytics::Events::ExperimentId
  • GoogleAnalytics::Events::ExperimentVariation

TODO: Add Double Click Snippet Support While the code is there, and it looks like it is simply changing the end path to the JS, this feature has not been tested.

Documentation

http://rubydoc.info/github/bgarret/google-analytics-rails

Example configurations

Production only

config/environments/production.rb:

# replace this with your tracker code
GA.tracker = "UA-112233-4"

app/views/layout/application.html.erb, in the <head> tag :

<%= analytics_init if GoogleAnalytics.valid_tracker? %>

With DoubleClick instead of vanilla Google Analytics script

config/environments/production.rb:

# replace this with your tracker code
GA.tracker = "UA-556677-8"
GA.script_source = :doubleclick

app/views/layout/application.html.erb, in the <head> tag :

<%= analytics_init if GoogleAnalytics.valid_tracker? %>

Different accounts for staging and production

config/environments/production.rb:

# replace this with your production tracker code
GA.tracker = "UA-990011-2"

config/environments/staging.rb:

# replace this with your staging tracker code
GA.tracker = "UA-334455-66"

app/views/layout/application.html.erb, in the <head> tag :

<%= analytics_init if GoogleAnalytics.valid_tracker? %>

Premium Google Analytics accounts

config/environments/production.rb:

# add this if you have a premium account and need to use the additional dimension/metric indices
# - premium accounts are allowed to have 200 custom dimensions/metrics
# - regular accounts are allowed 20
# see also: https://support.google.com/analytics/answer/2709828?hl=en#Limits
GA.premium_account = true

License

google-analytics-rails is released under the MIT license:

Thanks

Many thanks to the people that took time to submit patches.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap