rack-tracker 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +30 -8
- data/lib/rack/tracker/google_analytics/template/google_analytics.erb +1 -1
- data/lib/rack/tracker/version.rb +1 -1
- data/spec/handler/google_analytics_spec.rb +7 -3
- 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: 82d324245976135563761ec9eee0703f7557d0a2
|
4
|
+
data.tar.gz: dc0b22a2e177d364b14f9b2a178d97270aee2552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80ff2c12422960b315df641d81ed22ec2e48276942535f87f450c1cbf68b26be6dfd5a37d43d06e3464e9b4f295e570ad1ab09d48d9ff093439910d2f23cd1ec
|
7
|
+
data.tar.gz: 1453d60608ee4fa30e010489eef22c1704bb1bbe6a40c0289c6bafb897e7b16245c06cef80ad2fda0dada817ea9f92314d34be1f398a61963a6d03feeef62a91
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -17,8 +17,14 @@ an easy interface to drop in new services. This is why we created `rack-tracker`
|
|
17
17
|
rack middleware that can be hooked up to multiple services and exposing them in a unified
|
18
18
|
fashion. It comes in two parts, the first one is the actual middleware that you can add
|
19
19
|
to the middleware stack the second part are the service-handlers that you're going to use
|
20
|
-
in your application.
|
21
|
-
|
20
|
+
in your application. It's easy to add your own [custom handlers](#custom-handlers),
|
21
|
+
but to get you startet we're shipping support for the following services out of the box:
|
22
|
+
|
23
|
+
* [Google Analytics](#google-analytics)
|
24
|
+
* [Facebook](#facebook)
|
25
|
+
* [Visual Website Optimizer (VWO)](#visual-website-optimizer-vwo)
|
26
|
+
* [GoSquared](#gosquared)
|
27
|
+
|
22
28
|
|
23
29
|
## Installation
|
24
30
|
|
@@ -44,9 +50,7 @@ config.middleware.use(Rack::Tracker) do
|
|
44
50
|
end
|
45
51
|
````
|
46
52
|
|
47
|
-
This will add Google Analytics as a tracking handler.
|
48
|
-
support for Google Analytics and Facebook. Others might be added in the future
|
49
|
-
but you can easily write your own handlers.
|
53
|
+
This will add Google Analytics as a tracking handler.
|
50
54
|
|
51
55
|
### Google Analytics
|
52
56
|
|
@@ -218,10 +222,10 @@ It will render the following to the site source:
|
|
218
222
|
|
219
223
|
### Custom Handlers
|
220
224
|
|
221
|
-
Tough we give you
|
225
|
+
Tough we give you handlers for a few tracking services right out of the box, you might
|
222
226
|
be interested adding support for your custom tracking/analytics service.
|
223
227
|
|
224
|
-
Writing a handler is straight forward ;)
|
228
|
+
Writing a handler is straight forward ;) and there are just a couple of methods that
|
225
229
|
your class needs to implement.
|
226
230
|
|
227
231
|
Start with a plain ruby class that inherits from `Rack::Tracker::Handler`
|
@@ -242,7 +246,7 @@ end
|
|
242
246
|
```
|
243
247
|
|
244
248
|
This will render the `template/my_handler.erb` and inject the result into the source. You
|
245
|
-
can be creative about where the template is stored, we tend to have them around
|
249
|
+
can be creative about where the template is stored, but we tend to have them around
|
246
250
|
our actual handler code.
|
247
251
|
|
248
252
|
```erb
|
@@ -275,9 +279,27 @@ end
|
|
275
279
|
|
276
280
|
The snippit will then be rendered right before `</body>`.
|
277
281
|
|
282
|
+
To enable the *tracker dsl* functionality in your controllers
|
283
|
+
you need to implement the `track` class method on your handler:
|
284
|
+
|
285
|
+
```ruby
|
286
|
+
def self.track(name, *event)
|
287
|
+
# do something with the event(s) to prepare them for your template
|
288
|
+
# and return a hash with a signature like { name => event }
|
289
|
+
end
|
290
|
+
```
|
291
|
+
|
292
|
+
Checkout the existing handlers in `lib/rack/tracker` for some inspiration. :)
|
293
|
+
|
278
294
|
|
279
295
|
## Contributing
|
280
296
|
|
297
|
+
First of all, **thank** you for your help! :green_heart:
|
298
|
+
|
299
|
+
If you want a feature implemented, the best way to get it done
|
300
|
+
is to submit a pull request that implements it.
|
301
|
+
Tests, readme and changelog entries would be nice.
|
302
|
+
|
281
303
|
1. Fork it ( http://github.com/railslove/rack-tracker/fork )
|
282
304
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
283
305
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
data/lib/rack/tracker/version.rb
CHANGED
@@ -64,17 +64,21 @@ RSpec.describe Rack::Tracker::GoogleAnalytics do
|
|
64
64
|
def env
|
65
65
|
{'tracker' => {
|
66
66
|
'google_analytics' => [
|
67
|
-
Rack::Tracker::GoogleAnalytics::Ecommerce.new({type: 'addItem', id: '1234',
|
67
|
+
Rack::Tracker::GoogleAnalytics::Ecommerce.new({type: 'addItem', id: '1234', name: 'Fluffy Pink Bunnies', sku: 'DD23444', category: 'Party Toys', price: '11.99', quantity: '1'}),
|
68
|
+
Rack::Tracker::GoogleAnalytics::Ecommerce.new({type: 'addTransaction', id: '1234', affiliation: 'Acme Clothing', revenue: 11.99, shipping: '5', tax: '1.29', currency: 'EUR'})
|
68
69
|
]
|
69
70
|
}}
|
70
71
|
end
|
71
72
|
|
72
73
|
subject { described_class.new(env, tracker: 'somebody', ecommerce: true).render }
|
73
74
|
it "will add items" do
|
74
|
-
expect(subject).to match(%r{ga\(\"ecommerce:addItem\",#{{id: '1234',
|
75
|
+
expect(subject).to match(%r{ga\(\"ecommerce:addItem\",#{{id: '1234', name: 'Fluffy Pink Bunnies', sku: 'DD23444', category: 'Party Toys', price: '11.99', quantity: '1'}.to_json}})
|
76
|
+
end
|
77
|
+
it "will add transaction" do
|
78
|
+
expect(subject).to match(%r{ga\(\"ecommerce:addTransaction\",#{{id: '1234', affiliation: 'Acme Clothing', revenue: 11.99, shipping: '5', tax: '1.29', currency: 'EUR'}.to_json}})
|
75
79
|
end
|
76
80
|
it "will submit cart" do
|
77
|
-
expect(subject).to match(%r{ga\('send
|
81
|
+
expect(subject).to match(%r{ga\('ecommerce:send'\);})
|
78
82
|
end
|
79
83
|
end
|
80
84
|
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: 0.2.
|
4
|
+
version: 0.2.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: 2014-09-
|
12
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|