rack_utm 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +86 -23
- data/lib/rack_utm.rb +1 -1
- data/lib/rack_utm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba7edca42f7dfe760ef7d3cbec3a2dff3470bed49ed85609ccb860c5ea909c59
|
4
|
+
data.tar.gz: e62dcaa1a79651094e1f32f33acc68cff317054883a1944393e5505be935c9d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed216746f975a866b4f3f4fb2e2aa0d5cf34752d566965380839a4afefa056f859931ffcd39665bad908eb04deebcd35721ac332408b961cc70daf68e474dca6
|
7
|
+
data.tar.gz: 9c4286498c85360615b6a28a6692ab531aaa72884cd6341b3399ce6c5569d812ada48c697a6c5984290355bf990cac75e84342486f874e82a0abe8376c2c9a38
|
data/README.md
CHANGED
@@ -1,43 +1,106 @@
|
|
1
|
-
|
1
|
+
Rack::UTM
|
2
|
+
================
|
2
3
|
|
3
|
-
|
4
|
+
Rack::UTM is a rack middleware that extracts information about the utm tracking codes.
|
4
5
|
|
5
|
-
|
6
|
+
Common Scenario
|
7
|
+
---------------
|
6
8
|
|
7
|
-
|
9
|
+
UTM links tracking is very common task if you want to promote your online business. This middleware helps you to do that.
|
8
10
|
|
9
|
-
|
11
|
+
1. Use UTM Link to promote your business like <code>http://yoursite.org?utm_source=ABC123....</code>.
|
12
|
+
2. A user clicks through the link and lands on your site.
|
13
|
+
3. Rack::Utm middleware finds <code>utm_*</code> parameters in the request, extracts them and saves it in a cookie
|
14
|
+
4. User signs up (now or later) and you know the utm params the user has assigned
|
15
|
+
5. PROFIT!
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
```
|
17
|
+
Installation
|
18
|
+
------------
|
14
19
|
|
15
|
-
|
20
|
+
Piece a cake:
|
16
21
|
|
17
|
-
|
22
|
+
gem install rack_utm
|
18
23
|
|
19
|
-
Or install it yourself as:
|
20
24
|
|
21
|
-
|
25
|
+
Rails 3+ Example Usage
|
26
|
+
---------------------
|
22
27
|
|
23
|
-
|
28
|
+
Add the middleware to your application stack:
|
24
29
|
|
25
|
-
|
30
|
+
# Rails 3 App - in config/application.rb
|
31
|
+
class Application < Rails::Application
|
32
|
+
...
|
33
|
+
config.middleware.use Rack::Utm
|
34
|
+
...
|
35
|
+
end
|
26
36
|
|
27
|
-
|
37
|
+
# Rails 2 App - in config/environment.rb
|
38
|
+
Rails::Initializer.run do |config|
|
39
|
+
...
|
40
|
+
config.middleware.use "Rack::Utm"
|
41
|
+
...
|
42
|
+
end
|
28
43
|
|
29
|
-
|
44
|
+
Now you can check any request to see who came to your site via an affiliated link and use this information in your application. Affiliate tag is saved in the cookie and will come into play if user returns to your site later.
|
30
45
|
|
31
|
-
|
46
|
+
class ExampleController < ApplicationController
|
47
|
+
def index
|
48
|
+
str = if request.env['utm_source']
|
49
|
+
"Hallo, user! You've been referred here by #{request.env['utm_source']}, #{request.env['utm_medium']}, ...."
|
50
|
+
else
|
51
|
+
"We're glad you found us on your own!"
|
52
|
+
end
|
32
53
|
|
33
|
-
|
54
|
+
render :text => str
|
55
|
+
end
|
56
|
+
end
|
34
57
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/ihatov08/rack_utm. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
58
|
|
37
|
-
|
59
|
+
Customization
|
60
|
+
-------------
|
38
61
|
|
39
|
-
|
62
|
+
By default cookie is set for 30 days, you can extend time to live with <code>:ttl</code> option (default is 30 days).
|
40
63
|
|
41
|
-
|
64
|
+
#Rails 3+ in config/application.rb
|
65
|
+
class Application < Rails::Application
|
66
|
+
...
|
67
|
+
config.middleware.use Rack::Utm, { cookie_time_to_live: 60*60*24*30 }
|
68
|
+
...
|
69
|
+
end
|
42
70
|
|
43
|
-
|
71
|
+
The <code>:domain</code> option allows to customize cookie domain.
|
72
|
+
|
73
|
+
#Rails 3+ in config/application.rb
|
74
|
+
class Application < Rails::Application
|
75
|
+
...
|
76
|
+
config.middleware.use Rack::Utm, cookie_domain: '.example.org'
|
77
|
+
...
|
78
|
+
end
|
79
|
+
|
80
|
+
By default required parameters are `utm_source, utm_medium, utm_campaign, utm_content, utm_term`.
|
81
|
+
The <code>:required_parameters</code> option change required parameters.
|
82
|
+
|
83
|
+
#Rails 3+ in config/application.rb
|
84
|
+
class Application < Rails::Application
|
85
|
+
...
|
86
|
+
config.middleware.use Rack::Utm, required_parameters: %w[utm_source]
|
87
|
+
...
|
88
|
+
end
|
89
|
+
|
90
|
+
If you want to tracking optional parameters(not required), please use <code>optional_parameters</code> option.
|
91
|
+
|
92
|
+
#Rails 3+ in config/application.rb
|
93
|
+
class Application < Rails::Application
|
94
|
+
...
|
95
|
+
config.middleware.use Rack::Utm, optional_parameters: %w[optional_param]
|
96
|
+
...
|
97
|
+
end
|
98
|
+
|
99
|
+
Middleware will set cookie on <code>.example.org</code> so it's accessible on <code>www.example.org</code>, <code>app.example.org</code> etc.
|
100
|
+
|
101
|
+
The <code>:overwrite</code> option allows to set whether to overwrite the existing utm tag(`required_parameters`) previously stored in cookies. By default it is set to `true`.
|
102
|
+
|
103
|
+
Credits
|
104
|
+
=======
|
105
|
+
|
106
|
+
Thanks goes to Rack::Affiliates (https://github.com/alexlevin/rack-affiliates) for the inspiration.
|
data/lib/rack_utm.rb
CHANGED
data/lib/rack_utm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack_utm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ihatov08
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|