在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):kangguru/rack-google-analytics开源软件地址(OpenSource Url):https://github.com/kangguru/rack-google-analytics开源编程语言(OpenSource Language):Ruby 100.0%开源软件介绍(OpenSource Introduction):PLEASE READ:There is a new gem for various tracking and analytics services, which includes all the functionality of rack-google-analytics. So if you need more than just google, checkout the rack-tracker gem. Rack google AnalyticsSimple Rack middleware to help injecting the Google Analytics tracking code in your website. This middleware injects the Google Analytics tracking code into the correct place of any request only when the response's UsageGemfilegem 'rack-google-analytics' Sinatra## app.rb
use Rack::GoogleAnalytics, :tracker => 'UA-xxxxxx-x' Padrino## app/app.rb
use Rack::GoogleAnalytics, :tracker => 'UA-xxxxxx-x' Rails 3.X and Rails 4.X## application.rb:
config.middleware.use Rack::GoogleAnalytics, :tracker => 'UA-xxxxxx-x' Options
If you are not sure what's best, go with the defaults, and read here if you should opt-out. Event TrackingIn your application controller, you may track an event. For example: ga_track_event("Users", "Login", "Standard") See https://developers.google.com/analytics/devguides/collection/analyticsjs/events Custom PushIn your application controller, you may push arbritrary data. For example: ga_push("_addItem", "ID", "SKU") Dynamic Tracking CodeYou may instead define your tracking code as a lambda taking the Rack environment, so that you may set the tracking code dynamically based upon information in the Rack environment. For example: config.middleware.use Rack::GoogleAnalytics, :tracker => lambda { |env|
return env[:site_ga].tracker if env[:site_ga]
} Special use case: Event tracking onlyIf you already set up your Google Analytics
Thread SafetyThis middleware should be thread safe. Although my experience in such areas is limited, having taken the advice of those with more experience; I defer the call to a shallow copy of the environment, if this is of consequence to you please review the implementation. Note on Patches/Pull Requests
CopyrightCopyright (c) 2009-2012 Lee Hambley. See LICENSE for details. With thanks to Ralph von der Heyden and Simon Schoeters - And the biggest hand to Arthur Chiu for the huge work that went into the massive 0.9 re-factor. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论