markcatley-google_analytics 1.0.20080714 → 1.0.20080715

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/rubaidh/google_analytics.rb +13 -1
  2. metadata +1 -1
@@ -7,8 +7,14 @@ module Rubaidh # :nodoc:
7
7
  # An after_filter to automatically add the analytics code.
8
8
  # Add the code at the top of the page to support calls to _trackPageView
9
9
  # (see http://www.google.com/support/googleanalytics/bin/answer.py?answer=55527&topic=11006)
10
+ # If you're not going to use the link_to_tracked view helpers, you can set Rubaidh::GoogleAnalytics.defer_load = true
11
+ # to load the codel at the bottom of the page
10
12
  def add_google_analytics_code
11
- response.body.sub! '</body>', "#{google_analytics_code}</body>" if response.body.respond_to?(:sub!)
13
+ if GoogleAnalytics.defer_load
14
+ response.body.sub! '</body>', "#{google_analytics_code}</body>" if response.body.respond_to?(:sub!)
15
+ else
16
+ response.body.sub! '<body>', "<body>#{google_analytics_code}" if response.body.respond_to?(:sub!)
17
+ end
12
18
  end
13
19
  end
14
20
 
@@ -51,6 +57,12 @@ module Rubaidh # :nodoc:
51
57
  @@formats = [:html]
52
58
  cattr_accessor :formats
53
59
 
60
+ # Set this to true if you want to load the Analytics javascript at the bottom of
61
+ # each page rather than at the top. This may result in faster page render times,
62
+ # but may break link_to_tracked functionality.
63
+ @@defer_load = false
64
+ cattr_accessor :defer_load
65
+
54
66
  # Return true if the Google Analytics system is enabled and configured
55
67
  # correctly for the specified format
56
68
  def self.enabled?(format)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markcatley-google_analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.20080714
4
+ version: 1.0.20080715
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graeme Mathieson