googlets 0.0.5 → 0.0.6

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.
@@ -13,14 +13,14 @@ module Googlets
13
13
 
14
14
  # Google Analytics Asynchronous Tracking
15
15
  # http://code.google.com/intl/pl-PL/apis/analytics/docs/tracking/asyncUsageGuide.html
16
- def include_google_analytics(part = nil)
16
+ def include_google_analytics(part, options = {})
17
17
  return unless Googlets::Analytics.enabled?
18
18
 
19
19
  javascript_tag do
20
20
  case part
21
- when :head then Googlets::Analytics.head_javascript
22
- when :body then Googlets::Analytics.body_javascript
23
- else Googlets::Analytics.head_javascript + Googlets::Analytics.body_javascript
21
+ when :head then Googlets::Analytics.head(options[:queue])
22
+ when :body then Googlets::Analytics.body
23
+ else Googlets::Analytics.head(options[:queue]) + Googlets::Analytics.body
24
24
  end
25
25
  end
26
26
  end
@@ -30,11 +30,13 @@ module Googlets
30
30
 
31
31
  protected ##########################################################################################################
32
32
 
33
- def self.head_javascript
34
- "var _gaq = _gaq || []; _gaq.push(['_setAccount', '#{analytics_web_property_id}'], ['_trackPageview']);".html_safe
33
+ def self.head(queue = [])
34
+ queue = [queue] unless queue.blank? || queue.first.is_a?(Array)
35
+
36
+ "var _gaq = _gaq || []; _gaq.push(['_setAccount', '#{analytics_web_property_id}'], #{queue.map(&:to_json).join(', ') + ', ' unless queue.blank?}['_trackPageview']);".html_safe
35
37
  end
36
38
 
37
- def self.body_javascript
39
+ def self.body
38
40
  "(function() { " +
39
41
  "var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; " +
40
42
  "ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; " +
@@ -1,3 +1,3 @@
1
1
  module Googlets
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googlets
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - sodercober
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-04 00:00:00 +00:00
18
+ date: 2011-03-16 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies: []
21
21