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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7565da578c5c506a95014ea972db7008e870e034
4
- data.tar.gz: 4a735adf525fe516133d7c807472cc338d8b106b
3
+ metadata.gz: 4f96283c0c0a98829afd90e11bbd5e79d7286f52
4
+ data.tar.gz: 5ad6fa93e9419ac106f7c53dc7b07afcab142db7
5
5
  SHA512:
6
- metadata.gz: edae2548f40570b3068c4bcc9323fc869465add3be35d3fe856556a4702af888d1ebec860e9644e1df519b2bcc973d322accddb53bc23b5fc0712ef7d49d0930
7
- data.tar.gz: cbfc180230a44535c9d40c48fe82c7f9e4300f68ece15849dacc5789f46f348ccf497da7eaba24173d5d3567247579153ef85b89cb95c206934a1ab53fa97423
6
+ metadata.gz: 4006a72b6a23f2af2d29446842a93f0f6fc7392f75d539bb8344ffad99e81f8405ae365927bbcc58a7cf4848c90cfcbe95264ef86f5de6214895723a5d886caa
7
+ data.tar.gz: 39be467029907b418117f7c8457b5268c1dbf0a8ea656bf346d5d8c92f9374c75745d2bdc74625c0c02316a1f7fc36ca1c3b3b0461476f7b2a3e2926bf45c3ff
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 1.0.1
2
+
3
+ * [BUGFIX] Fix for adjusted_bounce_rate_timeouts #49 (thx @fabn)
4
+ * [BUGFIX] Do not pass string in mastertag when should be json #47 (thx @berlintam)
5
+
1
6
  # 1.0.0
2
7
 
3
8
  * [BUGFIX] breaking API change: set zanox path extension #45 (thx @berlintam)
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 %>
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Tracker
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
@@ -1,20 +1,18 @@
1
1
  <% if mastertag %>
2
-
3
- <div class="zx_<%= mastertag.id %> zx_mediaslot">
4
- <script type="text/javascript">
5
- window._zx = window._zx || [];
6
- window._zx.push({"id": "<%= mastertag.id %>"});
7
- (function(d) {
8
- var s = d.createElement("script"); s.async = true;
9
- s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//static.zanox.com/scripts/zanox.js";
10
- var a = d.getElementsByTagName("script")[0]; a.parentNode.insertBefore(s, a);
11
- }(document));
12
- </script>
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 match(%r{ga\('send', 'event', '15_seconds', 'read'\)})
263
- expect(subject).to match(%r{ga\('send', 'event', '30_seconds', 'read'\)})
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
@@ -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.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-07-20 00:00:00.000000000 Z
12
+ date: 2015-08-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack