google_analytics_tools 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,20 @@
1
1
  module GoogleAnalyticsTools
2
2
 
3
3
  class AsyncTrackingQueue
4
+
5
+ SCRIPT = <<-JAVASCRIPT
6
+ <script type="text/javascript">
7
+ (function() {
8
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
9
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
10
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
11
+ })();
12
+ </script>
13
+ JAVASCRIPT
14
+
15
+ def self.script
16
+ SCRIPT
17
+ end
4
18
 
5
19
  def initialize
6
20
  @events = []
@@ -19,11 +33,6 @@ module GoogleAnalyticsTools
19
33
  <script type="text/javascript">
20
34
  var _gaq = _gaq || [];
21
35
  #{@events.map { |event| event.to_s }.join("\n")}
22
- (function() {
23
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
24
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
25
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
26
- })();
27
36
  </script>
28
37
  JAVASCRIPT
29
38
  end
@@ -27,8 +27,12 @@ module GAQ::Events
27
27
  class TrackEvent < ::GAQ::Event
28
28
 
29
29
  def initialize(category, action, label = nil, value = nil)
30
- if label || value
31
- super('_trackEvent', category.to_s, action.to_s, label ? label.to_s : nil, value ? value.to_i : nil)
30
+ if label && value
31
+ super('_trackEvent', category.to_s, action.to_s, label, value)
32
+ elsif label
33
+ super('_trackEvent', category.to_s, action.to_s, label)
34
+ elsif value
35
+ super('_trackEvent', category.to_s, action.to_s, nil, value)
32
36
  else
33
37
  super('_trackEvent', category.to_s, action.to_s)
34
38
  end
@@ -1,3 +1,3 @@
1
1
  module GoogleAnalyticsTools
2
- VERSION = "0.2"
2
+ VERSION = "0.3"
3
3
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_analytics_tools
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- version: "0.2"
8
+ - 3
9
+ version: "0.3"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Scott Bauer