Module: Rubaidh::GoogleAnalyticsMixin
- Defined in:
- lib/rubaidh/google_analytics.rb
Instance Method Summary collapse
-
#add_google_analytics_code ⇒ Object
An after_filter to automatically add the analytics code.
- #google_analytics_code ⇒ Object
Instance Method Details
#add_google_analytics_code ⇒ Object
An after_filter to automatically add the analytics code. If you intend to use the link_to_tracked view helpers, you need to set Rubaidh::GoogleAnalytics.defer_load = false to load the code at the top of the page (see www.google.com/support/googleanalytics/bin/answer.py?answer=55527&topic=11006)
11 12 13 14 15 16 17 |
# File 'lib/rubaidh/google_analytics.rb', line 11 def add_google_analytics_code if GoogleAnalytics.defer_load response.body.sub! '</body>', "#{google_analytics_code}</body>" if response.body.respond_to?(:sub!) else response.body.sub! '<body>', "<body>#{google_analytics_code}" if response.body.respond_to?(:sub!) end end |
#google_analytics_code ⇒ Object
3 4 5 |
# File 'lib/rubaidh/google_analytics.rb', line 3 def google_analytics_code GoogleAnalytics.google_analytics_code(request.ssl?) if GoogleAnalytics.enabled?(request.format) end |