the_tracker 1.3.1 → 1.4.0

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- the_tracker (1.3.1)
4
+ the_tracker (1.4.0)
5
5
  rails
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -25,6 +25,8 @@ Currently this components are supported:
25
25
  Relevant Traffic Conversion Pixel
26
26
 
27
27
  YD RTB Pixel
28
+
29
+ Smart 4 Ads
28
30
 
29
31
  ## Installation
30
32
 
@@ -83,10 +85,12 @@ You can add a tracking code on a single page:
83
85
  TheTracker::Tracker.config do |tmf|
84
86
  tmf.add_once TheTracker::Trackers::Uservoice.new('YOUR_KEY', {:forum_id => 123, :tab_label => 'Say Hi and disappear!'})
85
87
  end
88
+
89
+ For more examples please visit [how to use it](https://github.com/jorgegorka/the_tracker/wiki/Usage)
86
90
 
87
91
  ## [Documentation](https://github.com/jorgegorka/the_tracker/wiki)
88
92
 
89
- Read the documentation to find details about how to implement each pixel available.
93
+ [Read the documentation](https://github.com/jorgegorka/the_tracker/wiki) to find details about how to implement each pixel available.
90
94
 
91
95
 
92
96
  ## Author
@@ -113,6 +117,12 @@ The Tracker is released under the [MIT License](http://www.opensource.org/licens
113
117
 
114
118
  ## Log
115
119
 
120
+ ### Version 1.4.0
121
+
122
+ Smart 4 Ads support
123
+
124
+ Universal analytics require libraries for demographic reports and enhanced link attribution
125
+
116
126
  ### Version 1.3.1
117
127
 
118
128
  Fixed gem generation problem
@@ -41,9 +41,12 @@ module TheTracker
41
41
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
42
42
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
43
43
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
44
- ga('create', '#{@options[:id]}', 'auto', {#{create_conf}});
45
- ga('#{name}.send', 'pageview');
44
+ ga('create', '#{@options[:id]}', {#{create_conf}});
45
+ ga('require', 'displayfeatures');
46
+ ga('require', 'linkid', 'linkid.js');
46
47
  #{extra_conf}
48
+ ga('#{name}.send', 'pageview');
49
+ #{set_transactions}
47
50
  </script>
48
51
  <!-- End Google Analytics -->
49
52
  EOF
@@ -71,22 +74,26 @@ module TheTracker
71
74
  conf = ''
72
75
  conf << "ga('#{name}.require', 'linker');\n"
73
76
  conf << "ga('linker:autoLink', #{@options[:domain_name]});\n" if @options[:domain_name]
74
- conf << set_custom_dimensions
75
- conf << set_custom_metrics
76
- conf << set_transactions
77
+ conf << set_custom_dimensions_and_metrics
77
78
  conf
78
79
  end
79
80
 
81
+ def set_custom_dimensions_and_metrics
82
+ all_custom = (set_custom_dimensions + set_custom_metrics).reject(&:empty?)
83
+ return '' if (all_custom.size < 1)
84
+ "ga('#{name}.set', {#{all_custom.join(', ')}});"
85
+ end
86
+
80
87
  def set_custom_dimensions
81
- custom_dimensions.map do | index, value |
82
- "ga('#{name}.set', 'dimension#{index}', '#{value}');"
83
- end.join(' ')
88
+ [custom_dimensions.map do | index, value |
89
+ "'dimension#{index}': '#{value}'"
90
+ end.join(', ')]
84
91
  end
85
92
 
86
93
  def set_custom_metrics
87
- custom_metrics.map do | index, value |
88
- "ga('#{name}.set', 'metric#{index}', '#{value}');"
89
- end.join(' ')
94
+ [custom_metrics.map do | index, value |
95
+ "'metric#{index}': '#{value}'"
96
+ end.join(', ')]
90
97
  end
91
98
 
92
99
  def set_transactions
@@ -0,0 +1,35 @@
1
+ module TheTracker
2
+ module Trackers
3
+ class Smart4Ads < Base
4
+
5
+ # Relevant info
6
+ def initialize(options)
7
+ @accountId = options[:accountId]
8
+ @orderId = options[:orderId]
9
+ @actionCode = options[:actionCode]
10
+ @totalCost = options[:totalCost]
11
+ @scriptId = options[:scriptId]
12
+ super()
13
+ end
14
+
15
+ def name
16
+ :smart4ads
17
+ end
18
+
19
+ def header
20
+ return if !active
21
+ <<-EOF
22
+ <script id="#{@scriptId}" src="https://www.smart4ads.com/smart4ads/scripts/simpletrackjs.js?accountid=#{@accountId}" type="text/javascript"></script>
23
+ EOF
24
+ end
25
+
26
+
27
+ def body_bottom
28
+ return if !active
29
+ <<-EOF
30
+ <script id="#{@scriptId}" src="https://www.smart4ads.com/smart4ads/api/PVTjs.php?accountid=#{@accountId}&totalcost=#{@totalCost}&orderid=#{@orderId}&actioncode=#{@actionCode}" type="text/javascript"></script>
31
+ EOF
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module TheTracker
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -13,7 +13,7 @@ describe TheTracker::Trackers::GUniversal do
13
13
  end
14
14
 
15
15
  it 'should return allow linker name content' do
16
- @ga.header.should include("ga('create', 'UA-111-22', 'auto', {'name': 'guniversal', 'allowLinker': true});")
16
+ @ga.header.should include("ga('create', 'UA-111-22', {'name': 'guniversal', 'allowLinker': true});")
17
17
  end
18
18
 
19
19
  it 'should return require linker' do
@@ -33,14 +33,22 @@ describe TheTracker::Trackers::GUniversal do
33
33
  describe :add_custom_dimension do
34
34
  it 'should add a custom dimension' do
35
35
  subject.add_custom_var(:dimension, 1, 'user')
36
- subject.header.should include("ga('guniversal.set', 'dimension1', 'user');")
36
+ subject.header.should include("ga('guniversal.set', {'dimension1': 'user'});")
37
37
  end
38
38
  end
39
39
 
40
40
  describe :add_custom_metric do
41
41
  it 'should add a custom metric' do
42
42
  subject.add_custom_var(:metric, 1, 999.99)
43
- subject.header.should include("ga('guniversal.set', 'metric1', '999.99');")
43
+ subject.header.should include("ga('guniversal.set', {'metric1': '999.99'});")
44
+ end
45
+ end
46
+
47
+ describe :add_both_custom do
48
+ it 'should add a custom metric and dimension' do
49
+ subject.add_custom_var(:dimension, 1, 'user')
50
+ subject.add_custom_var(:metric, 1, 999.99)
51
+ subject.header.should include("ga('guniversal.set', {'dimension1': 'user', 'metric1': '999.99'});")
44
52
  end
45
53
  end
46
54
 
@@ -94,7 +102,7 @@ describe TheTracker::Trackers::GUniversal do
94
102
  describe :add_user_id do
95
103
  it 'should return User Id' do
96
104
  subject.add_user_id('abcde123456')
97
- subject.header.should include("ga('create', 'UA-111-11', 'auto', {'name': 'guniversal', 'userId': 'abcde123456'});")
105
+ subject.header.should include("ga('create', 'UA-111-11', {'name': 'guniversal', 'userId': 'abcde123456'});")
98
106
  end
99
107
  end
100
108
  end
@@ -105,11 +113,11 @@ describe TheTracker::Trackers::GUniversal do
105
113
  end
106
114
 
107
115
  it 'should include UA information' do
108
- subject.header.should include("ga('create', 'UA-111-11', 'auto', {'name': 'guniversal'});")
116
+ subject.header.should include("ga('create', 'UA-111-11', {'name': 'guniversal'});")
109
117
  end
110
118
 
111
119
  it 'should not include linker information by default' do
112
- subject.header.should_not include("ga('create', 'UA-111-11', 'auto', {'allowLinker': true});")
120
+ subject.header.should_not include("ga('create', 'UA-111-11', {'allowLinker': true});")
113
121
  end
114
122
  end
115
123
 
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe TheTracker::Trackers::Smart4Ads do
4
+ subject { described_class.new(scriptId: 12345678, accountId: '9876543', totalCost: '0.00', orderId: 'PPEE44', actionCode: 'XX0099') }
5
+ describe :methods do
6
+ describe :body_bottom do
7
+ it 'should return ad_form content' do
8
+ subject.body_bottom.should include('://www.smart4ads.com/smart4ads/api/PVTjs.php')
9
+ end
10
+
11
+ it 'should include id, seg and orderID' do
12
+ subject.body_bottom.should include("script id=\"12345678\"");
13
+ subject.body_bottom.should include("accountid=9876543");
14
+ subject.body_bottom.should include("totalcost=0.00");
15
+ subject.body_bottom.should include("orderid=PPEE44");
16
+ subject.body_bottom.should include("actioncode=XX0099");
17
+ end
18
+
19
+ it 'returns nothing if tracker not active' do
20
+ subject.active = false
21
+ subject.body_bottom.should == nil
22
+ end
23
+ end
24
+ end
25
+ end
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.3.1
4
+ version: 1.4.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-21 00:00:00.000000000 Z
12
+ date: 2014-05-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -101,6 +101,7 @@ files:
101
101
  - lib/the_tracker/trackers/gtm.rb
102
102
  - lib/the_tracker/trackers/kenshoo.rb
103
103
  - lib/the_tracker/trackers/relevant.rb
104
+ - lib/the_tracker/trackers/smart4_ads.rb
104
105
  - lib/the_tracker/trackers/uservoice.rb
105
106
  - lib/the_tracker/trackers/yd.rb
106
107
  - lib/the_tracker/version.rb
@@ -115,6 +116,7 @@ files:
115
116
  - spec/the_tracker/trackers/gtm_spec.rb
116
117
  - spec/the_tracker/trackers/kenshoo_spec.rb
117
118
  - spec/the_tracker/trackers/relevant_spec.rb
119
+ - spec/the_tracker/trackers/smart4_ads_spec.rb
118
120
  - spec/the_tracker/trackers/uservoice_spec.rb
119
121
  - spec/the_tracker/trackers/yd_spec.rb
120
122
  - spec/the_tracker/view_helpers_spec.rb
@@ -131,12 +133,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
133
  - - ! '>='
132
134
  - !ruby/object:Gem::Version
133
135
  version: '0'
136
+ segments:
137
+ - 0
138
+ hash: -1917841728544294309
134
139
  required_rubygems_version: !ruby/object:Gem::Requirement
135
140
  none: false
136
141
  requirements:
137
142
  - - ! '>='
138
143
  - !ruby/object:Gem::Version
139
144
  version: '0'
145
+ segments:
146
+ - 0
147
+ hash: -1917841728544294309
140
148
  requirements: []
141
149
  rubyforge_project:
142
150
  rubygems_version: 1.8.24
@@ -155,7 +163,7 @@ test_files:
155
163
  - spec/the_tracker/trackers/gtm_spec.rb
156
164
  - spec/the_tracker/trackers/kenshoo_spec.rb
157
165
  - spec/the_tracker/trackers/relevant_spec.rb
166
+ - spec/the_tracker/trackers/smart4_ads_spec.rb
158
167
  - spec/the_tracker/trackers/uservoice_spec.rb
159
168
  - spec/the_tracker/trackers/yd_spec.rb
160
169
  - spec/the_tracker/view_helpers_spec.rb
161
- has_rdoc: