rack-tracker 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +6 -1
- data/lib/rack/tracker/google_analytics/template/google_analytics.erb +1 -1
- data/lib/rack/tracker/version.rb +1 -1
- data/lib/rack/tracker/zanox/template/zanox.erb +12 -14
- data/lib/rack/tracker/zanox/zanox.rb +6 -0
- data/spec/handler/google_analytics_spec.rb +2 -2
- data/spec/handler/zanox_spec.rb +15 -1
- data/spec/integration/zanox_integration_spec.rb +1 -0
- data/spec/support/metal_controller.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f96283c0c0a98829afd90e11bbd5e79d7286f52
|
4
|
+
data.tar.gz: 5ad6fa93e9419ac106f7c53dc7b07afcab142db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4006a72b6a23f2af2d29446842a93f0f6fc7392f75d539bb8344ffad99e81f8405ae365927bbcc58a7cf4848c90cfcbe95264ef86f5de6214895723a5d886caa
|
7
|
+
data.tar.gz: 39be467029907b418117f7c8457b5268c1dbf0a8ea656bf346d5d8c92f9374c75745d2bdc74625c0c02316a1f7fc36ca1c3b3b0461476f7b2a3e2926bf45c3ff
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -389,7 +389,7 @@ This is an example of a mastertag:
|
|
389
389
|
```
|
390
390
|
def show
|
391
391
|
tracker do |t|
|
392
|
-
t.zanox :mastertag, { id: "25GHTE9A07DF67DFG90T" }
|
392
|
+
t.zanox :mastertag, { id: "25GHTE9A07DF67DFG90T", category: 'Swimming', amount: '3.50' }
|
393
393
|
end
|
394
394
|
end
|
395
395
|
```
|
@@ -400,6 +400,11 @@ This will render to the follwing code in the JS:
|
|
400
400
|
window._zx.push({"id": "25GHTE9A07DF67DFG90T"});
|
401
401
|
```
|
402
402
|
|
403
|
+
and the following variables:
|
404
|
+
```
|
405
|
+
zx_category = 'Swimming';
|
406
|
+
zx_amount = '3.50';
|
407
|
+
|
403
408
|
#### Conversion tracking
|
404
409
|
|
405
410
|
This is an example of a lead event:
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<% end %>
|
26
26
|
<% if options[:adjusted_bounce_rate_timeouts] %>
|
27
27
|
<% options[:adjusted_bounce_rate_timeouts].each do |timeout| %>
|
28
|
-
setTimeout(ga('send', 'event', '<%= "#{timeout.to_s}_seconds" %>', 'read'),<%= timeout*1000 %>);
|
28
|
+
setTimeout(function() { ga('send', 'event', '<%= "#{timeout.to_s}_seconds" %>', 'read'); },<%= timeout*1000 %>);
|
29
29
|
<% end %>
|
30
30
|
<% end %>
|
31
31
|
<% end %>
|
data/lib/rack/tracker/version.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
<% if mastertag %>
|
2
|
-
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
</div>
|
14
|
-
|
2
|
+
<div class="zx_<%= mastertag.id %> zx_mediaslot">
|
3
|
+
<script type="text/javascript">
|
4
|
+
window._zx = window._zx || [];
|
5
|
+
window._zx.push({"id": "<%= mastertag.id %>"});
|
6
|
+
(function(d) {
|
7
|
+
var s = d.createElement("script"); s.async = true;
|
8
|
+
s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//static.zanox.com/scripts/zanox.js";
|
9
|
+
var a = d.getElementsByTagName("script")[0]; a.parentNode.insertBefore(s, a);
|
10
|
+
}(document));
|
11
|
+
<%= mastertag.write %>
|
12
|
+
</script>
|
13
|
+
</div>
|
15
14
|
<% end %>
|
16
15
|
|
17
|
-
|
18
16
|
<% sale_events.each do |event| %>
|
19
17
|
|
20
18
|
<script type="text/javascript" src="https://ad.zanox.com/pps/?<%= options[:account_id] %>&mode=[[1]]&<%= event.write %>">
|
@@ -3,6 +3,12 @@ class Rack::Tracker::Zanox < Rack::Tracker::Handler
|
|
3
3
|
# name of the handler
|
4
4
|
# everything after is passed as options
|
5
5
|
class Mastertag < OpenStruct
|
6
|
+
|
7
|
+
def write
|
8
|
+
to_h.except(:id).map do |k,v|
|
9
|
+
"var zx_#{k} = #{v.to_json};"
|
10
|
+
end.join("\n")
|
11
|
+
end
|
6
12
|
end
|
7
13
|
|
8
14
|
class Lead < OpenStruct
|
@@ -259,8 +259,8 @@ RSpec.describe Rack::Tracker::GoogleAnalytics do
|
|
259
259
|
subject { described_class.new(env, tracker: 'afake', adjusted_bounce_rate_timeouts: [15, 30]).render }
|
260
260
|
|
261
261
|
it "will add timeouts to push read events" do
|
262
|
-
expect(subject).to
|
263
|
-
expect(subject).to
|
262
|
+
expect(subject).to include %q{setTimeout(function() { ga('send', 'event', '15_seconds', 'read'); },15000)}
|
263
|
+
expect(subject).to include %q{setTimeout(function() { ga('send', 'event', '30_seconds', 'read'); },30000)}
|
264
264
|
end
|
265
265
|
end
|
266
266
|
end
|
data/spec/handler/zanox_spec.rb
CHANGED
@@ -9,6 +9,15 @@ RSpec.describe Rack::Tracker::Zanox do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
describe Rack::Tracker::Zanox::Mastertag do
|
13
|
+
|
14
|
+
subject { described_class.new(id: "25GHTE9A07DF67DFG90T", category: 'Swimming', amount: '3.50', products: [{amount: '5', currency: 'EUR'}, {amount: '6', currency: 'USD'}]) }
|
15
|
+
|
16
|
+
describe '#write' do
|
17
|
+
specify { expect(subject.write).to eq "var zx_category = \"Swimming\";\nvar zx_amount = \"3.50\";\nvar zx_products = [{\"amount\":\"5\",\"currency\":\"EUR\"},{\"amount\":\"6\",\"currency\":\"USD\"}];"}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
12
21
|
def env
|
13
22
|
{}
|
14
23
|
end
|
@@ -80,7 +89,10 @@ RSpec.describe Rack::Tracker::Zanox do
|
|
80
89
|
[
|
81
90
|
{
|
82
91
|
'id' => '12345678D2345',
|
83
|
-
'class_name' => 'Mastertag'
|
92
|
+
'class_name' => 'Mastertag',
|
93
|
+
'category' => 'Sewing',
|
94
|
+
'identifier' => '234',
|
95
|
+
'amount' => '5.90'
|
84
96
|
}
|
85
97
|
]
|
86
98
|
}
|
@@ -88,10 +100,12 @@ RSpec.describe Rack::Tracker::Zanox do
|
|
88
100
|
}
|
89
101
|
|
90
102
|
subject { described_class.new(env, options).render }
|
103
|
+
|
91
104
|
let(:options) { { account_id: '123456H123456' } }
|
92
105
|
|
93
106
|
it 'will display the correct tracking events' do
|
94
107
|
expect(subject).to include 'window._zx.push({"id": "12345678D2345"});'
|
108
|
+
expect(subject).to include "var zx_category = \"Sewing\";\nvar zx_identifier = \"234\";\nvar zx_amount = \"5.90\";\n"
|
95
109
|
end
|
96
110
|
end
|
97
111
|
end
|
@@ -14,6 +14,7 @@ RSpec.describe "Zanox Integration" do
|
|
14
14
|
|
15
15
|
it 'should include the mastertag event' do
|
16
16
|
expect(page.find("body")).to have_content "window._zx.push({\"id\": \"blurg567\"});"
|
17
|
+
expect(page).to have_content "var zx_category = \"cake decorating\";\nvar zx_amount = \"5.90\";\n"
|
17
18
|
end
|
18
19
|
|
19
20
|
it 'should include the sale event' do
|
@@ -77,7 +77,7 @@ class MetalController < ActionController::Metal
|
|
77
77
|
|
78
78
|
def zanox
|
79
79
|
tracker do |t|
|
80
|
-
t.zanox :mastertag, { id: 'blurg567'}
|
80
|
+
t.zanox :mastertag, { id: 'blurg567', category: 'cake decorating', amount: '5.90'}
|
81
81
|
t.zanox :sale, { customer_i_d: '123456', order_i_d: 'DEFC-4321', currency_symbol: 'EUR', total_price: '150.00' }
|
82
82
|
t.zanox :lead, { customer_i_d: '654321' }
|
83
83
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lars Brillert
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|