event_tracker 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 52bc0fa90b12fce477d49af6289838fed0bf5d53
4
+ data.tar.gz: a7c4949bf4442d2ac03d6f1806cb8ca4dbf0b2e9
5
+ SHA512:
6
+ metadata.gz: b9162174fa778c890e4ae9990c5f6bfce1f48f0d988674c2ebb75db9e6248f12ad8640ee9fbaa695d7efc21d3fc83c78ed77f01074b7c3695a4e933409ecc5bc
7
+ data.tar.gz: 55fc69bcaf73d92ebce53c9e10f61bac30845b84ebb3c5bbd8646b7e96286e918904a9701d327dabef96727df0eed4d620b565cac48a17779c6cd162e9d7883a
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Event Tracker
2
2
 
3
- Easy tracking using mixpanel or kissmetrics.
3
+ Easy tracking using mixpanel, kissmetrics, or Google Analytics (universal analytics).
4
4
 
5
5
  For details, see our guide to [tracking events](http://www.doorkeeperhq.com/developer/event-tracker-mixpanel-kissmetrics).
6
6
 
@@ -24,6 +24,7 @@ Or install it yourself as:
24
24
  # config/application.rb
25
25
  config.event_tracker.mixpanel_key = "YOUR_KEY"
26
26
  config.event_tracker.kissmetrics_key = "YOUR_KEY"
27
+ config.event_tracker.google_analytics_key = "YOUR_KEY"
27
28
 
28
29
  class ApplicationController < ActionController::Base
29
30
  around_filter :append_event_tracking_tags
@@ -45,6 +46,7 @@ end
45
46
  # in controller or views
46
47
  track_event("Event Name", optional_property: "value")
47
48
  register_properties(name: "value")
49
+ mixpanel_people_set( "property" => "value", "property" => "value")
48
50
  ```
49
51
 
50
52
  ## Todos
@@ -4,7 +4,7 @@ require File.expand_path('../lib/event_tracker/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Paul McMahon"]
6
6
  gem.email = ["paul@mobalean.com"]
7
- gem.description = %q{Easy integration with Mixpanel and Kissmetrics for Rails}
7
+ gem.description = %q{Easy integration with Mixpanel, Kissmetrics, and Google Analytics for Rails}
8
8
  gem.summary = %q{Track using javascript from your controllers, even when redirecting}
9
9
  gem.homepage = "http://www.doorkeeperhq.com/developer/event-tracker-mixpanel-kissmetrics"
10
10
 
@@ -1,6 +1,7 @@
1
1
  require "event_tracker/version"
2
2
  require "event_tracker/mixpanel"
3
3
  require "event_tracker/kissmetrics"
4
+ require "event_tracker/google_analytics"
4
5
 
5
6
  module EventTracker
6
7
  module HelperMethods
@@ -48,11 +49,19 @@ module EventTracker
48
49
  end
49
50
  end
50
51
 
52
+ def google_analytics_tracker
53
+ @google_analytics_tracker ||= begin
54
+ google_analytics_key = Rails.application.config.event_tracker.google_analytics_key
55
+ EventTracker::GoogleAnalytics.new(google_analytics_key) if google_analytics_key
56
+ end
57
+ end
58
+
51
59
  def event_trackers
52
60
  @event_trackers ||= begin
53
61
  trackers = []
54
62
  trackers << mixpanel_tracker if mixpanel_tracker
55
63
  trackers << kissmetrics_tracker if kissmetrics_tracker
64
+ trackers << google_analytics_tracker if google_analytics_tracker
56
65
  trackers
57
66
  end
58
67
  end
@@ -104,7 +113,7 @@ module EventTracker
104
113
  event_tracker_queue = session.delete(:event_tracker_queue)
105
114
 
106
115
  event_trackers.each do |tracker|
107
- a << tracker.register(registered_properties) if registered_properties.present?
116
+ a << tracker.register(registered_properties) if registered_properties.present? && tracker.respond_to?(:register)
108
117
 
109
118
  if event_tracker_queue.present?
110
119
  event_tracker_queue.each do |event_name, properties|
@@ -0,0 +1,21 @@
1
+ class EventTracker::GoogleAnalytics
2
+ def initialize(key)
3
+ @key = key
4
+ end
5
+
6
+ def init
7
+ <<-EOD
8
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
9
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
10
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
11
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
12
+
13
+ ga('create', '#{@key}', 'auto', {'name': 'event_tracker'});
14
+ ga('event_tracker.send', 'pageview');
15
+ EOD
16
+ end
17
+
18
+ def track(event_name, properties = {})
19
+ %Q{ga('event_tracker.send', 'event', 'event_tracker', '#{event_name}');}
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module EventTracker
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -4,6 +4,7 @@ shared_examples_for "init" do
4
4
  subject { page.find("head script").native.content }
5
5
  it { should include('mixpanel.init("YOUR_TOKEN")') }
6
6
  it { should include(%q{var _kmk = _kmk || 'KISSMETRICS_KEY'}) }
7
+ it { should include(%q{ga('create', 'GOOGLE_ANALYTICS_KEY', 'auto', {'name': 'event_tracker'});}) }
7
8
  end
8
9
 
9
10
  shared_examples_for "without distinct id" do
@@ -18,11 +19,13 @@ end
18
19
 
19
20
  shared_examples_for "without event" do
20
21
  it { should_not include('mixpanel.track("Register for site")') }
22
+ it { should_not include(%q{ga('event_tracker.send', 'event', 'event_tracker', 'Register for site');}) }
21
23
  end
22
24
 
23
25
  shared_examples_for "with event" do
24
26
  it { should include('mixpanel.track("Register for site")') }
25
27
  it { should include(%q{_kmq.push(['record', 'Register for site']);}) }
28
+ it { should include(%q{ga('event_tracker.send', 'event', 'event_tracker', 'Register for site');}) }
26
29
  end
27
30
 
28
31
  feature 'basic integration' do
@@ -15,6 +15,7 @@ app.config.action_dispatch.show_exceptions = false
15
15
 
16
16
  app.config.event_tracker.mixpanel_key = "YOUR_TOKEN"
17
17
  app.config.event_tracker.kissmetrics_key = "KISSMETRICS_KEY"
18
+ app.config.event_tracker.google_analytics_key = "GOOGLE_ANALYTICS_KEY"
18
19
 
19
20
  app.initialize!
20
21
 
metadata CHANGED
@@ -1,50 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Paul McMahon
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-03 00:00:00.000000000 Z
11
+ date: 2014-04-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
- requirement: &2160814880 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *2160814880
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: steak
27
- requirement: &2160812460 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - '>='
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *2160812460
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: capybara
38
- requirement: &2160821040 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
45
  - - ~>
42
46
  - !ruby/object:Gem::Version
43
47
  version: 2.0.3
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *2160821040
47
- description: Easy integration with Mixpanel and Kissmetrics for Rails
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.3
55
+ description: Easy integration with Mixpanel, Kissmetrics, and Google Analytics for
56
+ Rails
48
57
  email:
49
58
  - paul@mobalean.com
50
59
  executables: []
@@ -58,6 +67,7 @@ files:
58
67
  - Rakefile
59
68
  - event_tracker.gemspec
60
69
  - lib/event_tracker.rb
70
+ - lib/event_tracker/google_analytics.rb
61
71
  - lib/event_tracker/kissmetrics.rb
62
72
  - lib/event_tracker/mixpanel.rb
63
73
  - lib/event_tracker/version.rb
@@ -67,27 +77,26 @@ files:
67
77
  - spec/spec_helper.rb
68
78
  homepage: http://www.doorkeeperhq.com/developer/event-tracker-mixpanel-kissmetrics
69
79
  licenses: []
80
+ metadata: {}
70
81
  post_install_message:
71
82
  rdoc_options: []
72
83
  require_paths:
73
84
  - lib
74
85
  required_ruby_version: !ruby/object:Gem::Requirement
75
- none: false
76
86
  requirements:
77
- - - ! '>='
87
+ - - '>='
78
88
  - !ruby/object:Gem::Version
79
89
  version: '0'
80
90
  required_rubygems_version: !ruby/object:Gem::Requirement
81
- none: false
82
91
  requirements:
83
- - - ! '>='
92
+ - - '>='
84
93
  - !ruby/object:Gem::Version
85
94
  version: '0'
86
95
  requirements: []
87
96
  rubyforge_project:
88
- rubygems_version: 1.8.15
97
+ rubygems_version: 2.1.11
89
98
  signing_key:
90
- specification_version: 3
99
+ specification_version: 4
91
100
  summary: Track using javascript from your controllers, even when redirecting
92
101
  test_files:
93
102
  - spec/app/views/basic/in_views.html.erb