mixpanel 3.0.2 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  - [Usage] (#usage)
10
10
  - [Initialize Mixpanel] (#initialize-mixpanel)
11
11
  - [Track Events Directly](#track-events-directly)
12
+ - [Pixel Based Event Tracking](#pixel-based-event-tracking)
12
13
  - [Import Events](#import-events)
13
14
  - [Set Person Attributes Directly](#set-person-attributes-directly)
14
15
  - [Increment Person Attributes Directly](#increment-person-attributes-directly)
@@ -188,6 +189,25 @@ Example:
188
189
  @mixpanel.track 'Purchased credits', { :number => 5, 'First Time Buyer' => true }
189
190
  ```
190
191
 
192
+ ### Pixel Based Event Tracking
193
+
194
+ ```ruby
195
+ @mixpanel.tracking_pixel "Opened Email", { :distinct_id => "bob@email.com", :campaign => "Retarget" }
196
+ ```
197
+
198
+ This allows to track events just by loading a pixel. It's usually useful for tracking opened emails.
199
+ You've got to specify your own `distinct_id` as it won't be able to retrieve it from cookies.
200
+
201
+ And you can use it in your views with an image_tag helper:
202
+ ```ruby
203
+ image_tag @mixpanel.tracking_pixel("Opened Email", { :distinct_id => "bob@email.com", :campaign => "Retarget" }), :width => 1, :height => 1
204
+ ```
205
+
206
+
207
+ Mixpanel docs: https://mixpanel.com/docs/api-documentation/pixel-based-event-tracking
208
+
209
+
210
+
191
211
  ### Import Events
192
212
 
193
213
  ```ruby
@@ -377,3 +397,4 @@ end
377
397
  * [GBH](https://github.com/GBH)
378
398
  * [Goalee](https://github.com/Goalee)
379
399
  * [Ahmed Belal](https://github.com/AhmedBelal)
400
+ * [Esteban Pastorino](https://github.com/kitop)
@@ -6,6 +6,10 @@ module Mixpanel::Event
6
6
  def track(event, properties={}, options={})
7
7
  track_event event, properties, options, TRACK_URL
8
8
  end
9
+
10
+ def tracking_pixel(event, properties={}, options={})
11
+ build_url event, properties, options.merge(:url => TRACK_URL, :img => true)
12
+ end
9
13
 
10
14
  def import(event, properties={}, options={})
11
15
  track_event event, properties, options, IMPORT_URL
@@ -19,9 +23,7 @@ module Mixpanel::Event
19
23
 
20
24
  def track_event(event, properties, options, default_url)
21
25
  options.reverse_merge! :url => default_url, :async => @async, :api_key => @api_key
22
- data = build_event event, track_properties(properties)
23
- url = "#{options[:url]}?data=#{encoded_data(data)}"
24
- url += "&api_key=#{options[:api_key]}" if options[:api_key].present?
26
+ url = build_url event, properties, options
25
27
  parse_response request(url, options[:async])
26
28
  end
27
29
 
@@ -38,4 +40,12 @@ module Mixpanel::Event
38
40
  def build_event(event, properties)
39
41
  { :event => event, :properties => properties_hash(properties, EVENT_PROPERTIES) }
40
42
  end
41
- end
43
+
44
+ def build_url event, properties, options
45
+ data = build_event event, track_properties(properties)
46
+ url = "#{options[:url]}?data=#{encoded_data(data)}"
47
+ url << "&api_key=#{options[:api_key]}" if options[:api_key].present?
48
+ url << "&img=1" if options[:img]
49
+ url
50
+ end
51
+ end
data/mixpanel.gemspec CHANGED
@@ -2,7 +2,7 @@ files = ['README.md', 'LICENSE', 'Rakefile', 'mixpanel.gemspec', '{spec,lib}/**/
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
4
  s.name = "mixpanel"
5
- s.version = "3.0.2"
5
+ s.version = "3.1.0"
6
6
  s.rubyforge_project = "mixpanel"
7
7
  s.description = "Simple lib to track events in Mixpanel service. It can be used in any rack based framework."
8
8
  s.author = "Alvaro Gil"
@@ -30,6 +30,16 @@ describe Mixpanel::Tracker do
30
30
  @mixpanel.track('Sign up', { :likeable => true }, { :api_key => 'asdf' }).should == true
31
31
  end
32
32
  end
33
+
34
+ context "Tracking pixel" do
35
+ it "should return a URL" do
36
+ @mixpanel.tracking_pixel("Sign up").should be_a(String)
37
+ end
38
+
39
+ it "should include img=1" do
40
+ @mixpanel.tracking_pixel("Sign up").should match(/&img=1/)
41
+ end
42
+ end
33
43
 
34
44
  context "Importing events" do
35
45
  it "should import simple events" do
metadata CHANGED
@@ -1,134 +1,172 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mixpanel
3
- version: !ruby/object:Gem::Version
4
- version: 3.0.2
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: 3
5
+ prerelease: false
6
+ segments:
7
+ - 3
8
+ - 1
9
+ - 0
10
+ version: 3.1.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Alvaro Gil
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-10-26 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-11-13 00:00:00 -02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: json
16
- requirement: &2153672300 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
22
33
  type: :runtime
23
- prerelease: false
24
- version_requirements: *2153672300
25
- - !ruby/object:Gem::Dependency
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
26
36
  name: rack
27
- requirement: &2153671860 !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
28
39
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
33
47
  type: :runtime
34
- prerelease: false
35
- version_requirements: *2153671860
36
- - !ruby/object:Gem::Dependency
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
37
50
  name: escape
38
- requirement: &2153671440 !ruby/object:Gem::Requirement
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
39
53
  none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
44
61
  type: :runtime
45
- prerelease: false
46
- version_requirements: *2153671440
47
- - !ruby/object:Gem::Dependency
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
48
64
  name: active_support
49
- requirement: &2153671020 !ruby/object:Gem::Requirement
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
50
67
  none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
55
75
  type: :development
56
- prerelease: false
57
- version_requirements: *2153671020
58
- - !ruby/object:Gem::Dependency
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
59
78
  name: rspec
60
- requirement: &2153670600 !ruby/object:Gem::Requirement
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
61
81
  none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
65
- version: '0'
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
66
89
  type: :development
67
- prerelease: false
68
- version_requirements: *2153670600
69
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
70
92
  name: rack-test
71
- requirement: &2153670180 !ruby/object:Gem::Requirement
93
+ prerelease: false
94
+ requirement: &id006 !ruby/object:Gem::Requirement
72
95
  none: false
73
- requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
76
- version: '0'
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
77
103
  type: :development
78
- prerelease: false
79
- version_requirements: *2153670180
80
- - !ruby/object:Gem::Dependency
104
+ version_requirements: *id006
105
+ - !ruby/object:Gem::Dependency
81
106
  name: fakeweb
82
- requirement: &2153669760 !ruby/object:Gem::Requirement
107
+ prerelease: false
108
+ requirement: &id007 !ruby/object:Gem::Requirement
83
109
  none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
116
+ version: "0"
88
117
  type: :development
89
- prerelease: false
90
- version_requirements: *2153669760
91
- - !ruby/object:Gem::Dependency
118
+ version_requirements: *id007
119
+ - !ruby/object:Gem::Dependency
92
120
  name: nokogiri
93
- requirement: &2153669340 !ruby/object:Gem::Requirement
121
+ prerelease: false
122
+ requirement: &id008 !ruby/object:Gem::Requirement
94
123
  none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: '0'
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 3
128
+ segments:
129
+ - 0
130
+ version: "0"
99
131
  type: :development
100
- prerelease: false
101
- version_requirements: *2153669340
102
- - !ruby/object:Gem::Dependency
132
+ version_requirements: *id008
133
+ - !ruby/object:Gem::Dependency
103
134
  name: rake
104
- requirement: &2153668920 !ruby/object:Gem::Requirement
135
+ prerelease: false
136
+ requirement: &id009 !ruby/object:Gem::Requirement
105
137
  none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ hash: 3
142
+ segments:
143
+ - 0
144
+ version: "0"
110
145
  type: :development
146
+ version_requirements: *id009
147
+ - !ruby/object:Gem::Dependency
148
+ name: ruby-debug
111
149
  prerelease: false
112
- version_requirements: *2153668920
113
- - !ruby/object:Gem::Dependency
114
- name: ruby-debug19
115
- requirement: &2160944480 !ruby/object:Gem::Requirement
150
+ requirement: &id010 !ruby/object:Gem::Requirement
116
151
  none: false
117
- requirements:
118
- - - ! '>='
119
- - !ruby/object:Gem::Version
120
- version: '0'
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ hash: 3
156
+ segments:
157
+ - 0
158
+ version: "0"
121
159
  type: :development
122
- prerelease: false
123
- version_requirements: *2160944480
124
- description: Simple lib to track events in Mixpanel service. It can be used in any
125
- rack based framework.
160
+ version_requirements: *id010
161
+ description: Simple lib to track events in Mixpanel service. It can be used in any rack based framework.
126
162
  email: zevarito@gmail.com
127
163
  executables: []
164
+
128
165
  extensions: []
129
- extra_rdoc_files:
166
+
167
+ extra_rdoc_files:
130
168
  - README.md
131
- files:
169
+ files:
132
170
  - README.md
133
171
  - LICENSE
134
172
  - Rakefile
@@ -144,28 +182,39 @@ files:
144
182
  - lib/mixpanel/subprocess.rb
145
183
  - lib/mixpanel/tracker.rb
146
184
  - lib/mixpanel.rb
185
+ has_rdoc: true
147
186
  homepage: http://github.com/zevarito/mixpanel
148
187
  licenses: []
188
+
149
189
  post_install_message:
150
190
  rdoc_options: []
151
- require_paths:
191
+
192
+ require_paths:
152
193
  - lib
153
- required_ruby_version: !ruby/object:Gem::Requirement
194
+ required_ruby_version: !ruby/object:Gem::Requirement
154
195
  none: false
155
- requirements:
156
- - - ! '>='
157
- - !ruby/object:Gem::Version
158
- version: '0'
159
- required_rubygems_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ hash: 3
200
+ segments:
201
+ - 0
202
+ version: "0"
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
204
  none: false
161
- requirements:
162
- - - ! '>='
163
- - !ruby/object:Gem::Version
164
- version: '0'
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ hash: 3
209
+ segments:
210
+ - 0
211
+ version: "0"
165
212
  requirements: []
213
+
166
214
  rubyforge_project: mixpanel
167
- rubygems_version: 1.8.15
215
+ rubygems_version: 1.3.7
168
216
  signing_key:
169
217
  specification_version: 3
170
218
  summary: Supports direct request api and javascript requests through a middleware.
171
219
  test_files: []
220
+