the_tracker 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -133
- data/lib/the_tracker/trackers/yd.rb +26 -0
- data/lib/the_tracker/version.rb +1 -1
- data/spec/the_tracker/trackers/yd_spec.rb +36 -0
- data/the_tracker-1.2.3.gem +0 -0
- data/the_tracker.gemspec +2 -2
- metadata +10 -4
data/README.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/the_tracker.svg)](http://badge.fury.io/rb/the_tracker)
|
2
|
+
|
3
|
+
Simple way to add Google analytics, universal analytics, uservoice to your rails app
|
4
|
+
|
1
5
|
# TheTracker
|
2
6
|
|
3
7
|
A Gem to help you add tracker components to your application. Instead of having to write javascript code to add this trackers you can use plain pure ruby.
|
@@ -20,6 +24,8 @@ Currently this components are supported:
|
|
20
24
|
|
21
25
|
Relevant Traffic Conversion Pixel
|
22
26
|
|
27
|
+
YD RTB Pixel
|
28
|
+
|
23
29
|
## Installation
|
24
30
|
|
25
31
|
Add this line to your application's Gemfile:
|
@@ -65,7 +71,7 @@ And that's all, the tracking code will be added automatically
|
|
65
71
|
|
66
72
|
Sometimes you only want to track certain pages:
|
67
73
|
|
68
|
-
For instance, this example will
|
74
|
+
For instance, this example will show the Google Analytics code only if `some_condition` evaluates to true
|
69
75
|
|
70
76
|
<header>
|
71
77
|
<% TheTracker::Tracker.instance.trackers[:ganalytics].active = some_condition %>
|
@@ -78,140 +84,10 @@ You can add a tracking code on a single page:
|
|
78
84
|
tmf.add_once TheTracker::Trackers::Uservoice.new('YOUR_KEY', {:forum_id => 123, :tab_label => 'Say Hi and disappear!'})
|
79
85
|
end
|
80
86
|
|
87
|
+
## [Documentation](https://github.com/jorgegorka/the_tracker/wiki)
|
81
88
|
|
82
|
-
|
83
|
-
|
84
|
-
### AdFrom
|
85
|
-
|
86
|
-
TheTracker::Trackers::AdForm.new(:pm => 123, :id => 444)
|
87
|
-
|
88
|
-
### Uservoice
|
89
|
-
|
90
|
-
TheTracker::Trackers::Uservoice.new(
|
91
|
-
'THE_KEY',
|
92
|
-
{
|
93
|
-
mode: 'full',
|
94
|
-
primary_color: '#ff0000',
|
95
|
-
link_color: '#007dbf',
|
96
|
-
default_mode: 'support',
|
97
|
-
forum_id: 111,
|
98
|
-
tab_label: 'Say Hi!',
|
99
|
-
tab_color: '#cc0000',
|
100
|
-
tab_position: 'middle-left',
|
101
|
-
tab_inverted: true
|
102
|
-
}
|
103
|
-
)
|
104
|
-
|
105
|
-
### Google Analytics
|
106
|
-
|
107
|
-
#### Regular tracking code
|
108
|
-
TheTracker::Trackers::GAnalytics.new(:id => 'UA-111111-11')
|
109
|
-
|
110
|
-
You can optionally set domain name and allow linker
|
111
|
-
|
112
|
-
TheTracker::Trackers::GAnalytics.new(:id => 'UA-111111-11', :domain_name => 'mydomain.com', :allow_linker => true)
|
113
|
-
|
114
|
-
#### Add an e-commerce transaction
|
115
|
-
TheTracker::Tracker.instance.trackers[:ganalytics].add_transaction(tid=0, store='', total=0, tax=0, shipping=0, city='', state='', country='')
|
116
|
-
|
117
|
-
Yo don't need to specify an id. If id is zero the transaction id will be the current timestamp
|
118
|
-
|
119
|
-
To add items to the transaction:
|
120
|
-
|
121
|
-
TheTracker::Tracker.instance.trackers[:ganalytics].add_transaction_item(sku='', product='', category='', price=0, quantity=0)
|
122
|
-
|
123
|
-
#### Add custom vars
|
124
|
-
|
125
|
-
TheTracker::Tracker.instance.trackers[:ganalytics].add_custom_var(index, name, value, scope)
|
126
|
-
|
127
|
-
#### Track an event
|
128
|
-
|
129
|
-
TheTracker::Tracker.instance.trackers[:ganalytics].track_event(category, action, label='', value=0, non_interactive=false)
|
130
|
-
|
131
|
-
### Google Universal Analytics
|
132
|
-
|
133
|
-
#### Regular tracking code
|
134
|
-
TheTracker::Trackers::GUniversal.new(:id => 'UA-111111-11')
|
135
|
-
|
136
|
-
You can optionally set an array of domains and allow linker
|
137
|
-
|
138
|
-
TheTracker::Trackers::GUniversal.new(:id => 'UA-111111-11', :domain_name => ['onedomain.com', 'anotherdomain.com'], :allow_linker => true)
|
139
|
-
|
140
|
-
#### Track multiple analytics accounts
|
141
|
-
|
142
|
-
All tracking codes are namespaced to avoid conflicts with other existant Universal analytics accounts or to allow you to use more than one account.
|
89
|
+
Read the documentation to find details about how to implement each pixel available.
|
143
90
|
|
144
|
-
If you create an account without specifiying a name the default name will be 'guniversal':
|
145
|
-
TheTracker::Trackers::GUniversal.new(:id => 'UA-111111-11')
|
146
|
-
|
147
|
-
the code that will be injected on the page will be like this:
|
148
|
-
ga('guniversal.send', 'pageview');
|
149
|
-
|
150
|
-
If you want to add another universal analytics account you should define a name when creating it:
|
151
|
-
TheTracker::Trackers::GUniversal.new(id: 'UA-111111-11', name: 'second_account')
|
152
|
-
|
153
|
-
and the code generated will be like this:
|
154
|
-
ga('second_account.send', 'pageview');
|
155
|
-
|
156
|
-
To add information to a specific account just use the appropiate tracker
|
157
|
-
TheTracker::Tracker.instance.trackers[:second_account].add_custom_var(:dimension, 1, 'I am second to none')
|
158
|
-
|
159
|
-
#### Add an e-commerce transaction
|
160
|
-
TheTracker::Tracker.instance.trackers[:guniversal].add_transaction(tid=0, store='', total=0, tax=0, shipping=0)
|
161
|
-
|
162
|
-
Yo don't need to specify an id. If id is zero the transaction id will be the current timestamp
|
163
|
-
|
164
|
-
To add items to the transaction:
|
165
|
-
|
166
|
-
TheTracker::Tracker.instance.trackers[:guniversal].add_transaction_item(sku='', product='', category='', price=0, quantity=0)
|
167
|
-
|
168
|
-
#### Add custom dimensions and metrics
|
169
|
-
|
170
|
-
TheTracker::Tracker.instance.trackers[:guniversal].add_custom_var(:dimension, index, value)
|
171
|
-
TheTracker::Tracker.instance.trackers[:guniversal].add_custom_var(:metric, index, value)
|
172
|
-
|
173
|
-
#### Add User Id
|
174
|
-
|
175
|
-
TheTracker::Tracker.instance.trackers[:guniversal].add_user_id(id)
|
176
|
-
|
177
|
-
### Google Tag Manager
|
178
|
-
|
179
|
-
TheTracker::Trackers::Gtm.new(:gtmid => 'GTM-111111')
|
180
|
-
|
181
|
-
To add [dataLayer variables to GTM](https://developers.google.com/tag-manager/devguide)
|
182
|
-
|
183
|
-
TheTracker::Tracker.instance.trackers[:gtm].add_data_layer(name, value)
|
184
|
-
|
185
|
-
### Google AdServices
|
186
|
-
|
187
|
-
TheTracker::Trackers::GAdServices.new(
|
188
|
-
id: 'UA-111111-11'
|
189
|
-
language: 'en',
|
190
|
-
format: '1',
|
191
|
-
color: 'ffffff',
|
192
|
-
label: 'qwerty',
|
193
|
-
value: '0'
|
194
|
-
)
|
195
|
-
|
196
|
-
### Kenshoo Conversion Pixel
|
197
|
-
|
198
|
-
TheTracker::Trackers::Kenshoo.new(
|
199
|
-
token: '999'
|
200
|
-
type: 'conv',
|
201
|
-
val: '0',
|
202
|
-
orderId: '88988',
|
203
|
-
promoCode: 'easter',
|
204
|
-
valueCurrency: 'EUR',
|
205
|
-
trackEvent: '1234'
|
206
|
-
)
|
207
|
-
|
208
|
-
### Relevant Traffic Conversion Pixel
|
209
|
-
|
210
|
-
TheTracker::Trackers::Relevant.new(
|
211
|
-
token: '4329847'
|
212
|
-
seg: '289347',
|
213
|
-
orderId: '88AB988'
|
214
|
-
)
|
215
91
|
|
216
92
|
## Author
|
217
93
|
|
@@ -237,6 +113,10 @@ The Tracker is released under the [MIT License](http://www.opensource.org/licens
|
|
237
113
|
|
238
114
|
## Log
|
239
115
|
|
116
|
+
### Version 1.3.0
|
117
|
+
|
118
|
+
YD RTB support
|
119
|
+
|
240
120
|
### Version 1.2.3
|
241
121
|
|
242
122
|
Fixed bug with namespace
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module TheTracker
|
2
|
+
module Trackers
|
3
|
+
class Yd < Base
|
4
|
+
|
5
|
+
# Yd info
|
6
|
+
def initialize(options)
|
7
|
+
@id = options[:id]
|
8
|
+
@product = options[:product ]
|
9
|
+
@order_id = options[:order_id]
|
10
|
+
@cookies = options.delete(:cookies_allowed) || 1
|
11
|
+
super()
|
12
|
+
end
|
13
|
+
|
14
|
+
def name
|
15
|
+
:yd
|
16
|
+
end
|
17
|
+
|
18
|
+
def body_bottom
|
19
|
+
return if !active
|
20
|
+
<<-EOF
|
21
|
+
<iframe src="https://d.254a.com/pixel?id=#{@id}&t=3&cookies_allowed=#{@cookies}&orderid=#{@order_id}&product=#{@product}&secure=true" width="0" height="0" style="display:none;visibility:hidden"></iframe>
|
22
|
+
EOF
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/the_tracker/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TheTracker::Trackers::Yd do
|
4
|
+
subject { described_class.new(id: 12345678, product: '9876543', order_id: '2', cookies_allowed: 1) }
|
5
|
+
describe :methods do
|
6
|
+
describe :body_bottom do
|
7
|
+
it 'should return ad_form content' do
|
8
|
+
subject.body_bottom.should include('https://d.254a.com')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should include id, seg and orderID' do
|
12
|
+
subject.body_bottom.should include("id=12345678");
|
13
|
+
subject.body_bottom.should include("product=9876543");
|
14
|
+
subject.body_bottom.should include("orderid=2");
|
15
|
+
subject.body_bottom.should include("cookies_allowed=1");
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns nothing if tracker not active' do
|
19
|
+
subject.active = false
|
20
|
+
subject.body_bottom.should == nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe :cookiesAllowed do
|
25
|
+
context 'when cookiesAllowed is not set in the params' do
|
26
|
+
before :each do
|
27
|
+
@yd_tracker = described_class.new(id: 12345678, product: '9876543', order_id: '2')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should be 1' do
|
31
|
+
@yd_tracker.body_bottom.should include("cookies_allowed=1");
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
Binary file
|
data/the_tracker.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = TheTracker::VERSION
|
9
9
|
gem.authors = ["Jorge Alvarez"]
|
10
10
|
gem.email = ["jorge@alvareznavarro.es"]
|
11
|
-
gem.description = %q{
|
12
|
-
gem.summary = %q{Analytics,
|
11
|
+
gem.description = %q{Simple way to add Google analytics, universal analytics, uservoice, etc. to your rails app}
|
12
|
+
gem.summary = %q{Add tracking pixels like Analytics, Universal Analytics, RTB, remarketing, etc...}
|
13
13
|
gem.homepage = ""
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -75,7 +75,8 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
-
description:
|
78
|
+
description: Simple way to add Google analytics, universal analytics, uservoice, etc.
|
79
|
+
to your rails app
|
79
80
|
email:
|
80
81
|
- jorge@alvareznavarro.es
|
81
82
|
executables: []
|
@@ -101,6 +102,7 @@ files:
|
|
101
102
|
- lib/the_tracker/trackers/kenshoo.rb
|
102
103
|
- lib/the_tracker/trackers/relevant.rb
|
103
104
|
- lib/the_tracker/trackers/uservoice.rb
|
105
|
+
- lib/the_tracker/trackers/yd.rb
|
104
106
|
- lib/the_tracker/version.rb
|
105
107
|
- lib/the_tracker/view_helpers.rb
|
106
108
|
- spec/spec_helper.rb
|
@@ -114,7 +116,9 @@ files:
|
|
114
116
|
- spec/the_tracker/trackers/kenshoo_spec.rb
|
115
117
|
- spec/the_tracker/trackers/relevant_spec.rb
|
116
118
|
- spec/the_tracker/trackers/uservoice_spec.rb
|
119
|
+
- spec/the_tracker/trackers/yd_spec.rb
|
117
120
|
- spec/the_tracker/view_helpers_spec.rb
|
121
|
+
- the_tracker-1.2.3.gem
|
118
122
|
- the_tracker.gemspec
|
119
123
|
homepage: ''
|
120
124
|
licenses: []
|
@@ -139,7 +143,8 @@ rubyforge_project:
|
|
139
143
|
rubygems_version: 1.8.24
|
140
144
|
signing_key:
|
141
145
|
specification_version: 3
|
142
|
-
summary: Analytics,
|
146
|
+
summary: Add tracking pixels like Analytics, Universal Analytics, RTB, remarketing,
|
147
|
+
etc...
|
143
148
|
test_files:
|
144
149
|
- spec/spec_helper.rb
|
145
150
|
- spec/the_tracker/tracker_spec.rb
|
@@ -152,5 +157,6 @@ test_files:
|
|
152
157
|
- spec/the_tracker/trackers/kenshoo_spec.rb
|
153
158
|
- spec/the_tracker/trackers/relevant_spec.rb
|
154
159
|
- spec/the_tracker/trackers/uservoice_spec.rb
|
160
|
+
- spec/the_tracker/trackers/yd_spec.rb
|
155
161
|
- spec/the_tracker/view_helpers_spec.rb
|
156
162
|
has_rdoc:
|