rack-utm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +88 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 04985930656d4510deea4ea24cd7da8ce4da5a77
|
4
|
+
data.tar.gz: 22f89051a7956275054f544c5e202cf4678e8cdf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 723146a7b42519a318756043f0cf7fc1d40c6dc128e606e92c0f9938029de386874a8e2f8958ec9552976c9befb358d6ce142cadeebbba088d8ce897d5d1c25b
|
7
|
+
data.tar.gz: be5e4341e83cbd597274afbc870e059d98c7632e5ec2b472bf26be08dd6cd56e81b4ca96f3f547cb0f3b216e04b74ea8abefe51a00bd250f85526892f3708706
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Alex Levin
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
Rack::UTM
|
2
|
+
================
|
3
|
+
|
4
|
+
Rack::UTM is a rack middleware that extracts information about the utm tracking codes. Specifically, it looks up for specific parameter (<code>utm-*</code> by default) in the request. If found, it persists utm tag values in a cookie for later use.
|
5
|
+
|
6
|
+
Common Scenario
|
7
|
+
---------------
|
8
|
+
|
9
|
+
UTM links tracking is very common task if you want to promote your online business. This middleware helps you to do that.
|
10
|
+
|
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!
|
16
|
+
|
17
|
+
Installation
|
18
|
+
------------
|
19
|
+
|
20
|
+
Piece a cake:
|
21
|
+
|
22
|
+
gem install rack-utm
|
23
|
+
|
24
|
+
|
25
|
+
Rails 3 Example Usage
|
26
|
+
---------------------
|
27
|
+
|
28
|
+
Add the middleware to your application stack:
|
29
|
+
|
30
|
+
# Rails 3 App - in config/application.rb
|
31
|
+
class Application < Rails::Application
|
32
|
+
...
|
33
|
+
config.middleware.use Rack::Utm
|
34
|
+
...
|
35
|
+
end
|
36
|
+
|
37
|
+
# Rails 2 App - in config/environment.rb
|
38
|
+
Rails::Initializer.run do |config|
|
39
|
+
...
|
40
|
+
config.middleware.use "Rack::Utm"
|
41
|
+
...
|
42
|
+
end
|
43
|
+
|
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.
|
45
|
+
|
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
|
53
|
+
|
54
|
+
render :text => str
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
Customization
|
60
|
+
-------------
|
61
|
+
|
62
|
+
By default cookie is set for 30 days, you can extend time to live with <code>:ttl</code> option (default is 30 days).
|
63
|
+
|
64
|
+
#Rails 3 in config/application.rb
|
65
|
+
class Application < Rails::Application
|
66
|
+
...
|
67
|
+
config.middleware.use Rack::Affiliates, {:ttl => 3.months}
|
68
|
+
...
|
69
|
+
end
|
70
|
+
|
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::Affiliates, :domain => '.example.org'
|
77
|
+
...
|
78
|
+
end
|
79
|
+
|
80
|
+
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.
|
81
|
+
|
82
|
+
The <code>:overwrite</code> option allows to set whether to overwrite the existing utm tag previously stored in cookies. By default it is set to `true`.
|
83
|
+
|
84
|
+
Credits
|
85
|
+
=======
|
86
|
+
|
87
|
+
Thanks goes to Rack::Referrals (https://github.com/deviantech/rack-referrals) and Rack::Affiliates (https://github.com/alexlevin/rack-affiliates) for the inspiration.
|
88
|
+
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-utm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Severin Ulrich
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.6.2
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.6.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jeweler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.4
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.4
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack-test
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: timecop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: If the user clicked through from an affiliated site, this middleware
|
112
|
+
will track affiliate tag, referring url and time.
|
113
|
+
email: novolab@novotec.ch
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files:
|
117
|
+
- LICENSE.txt
|
118
|
+
- README.md
|
119
|
+
files:
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
homepage: http://github.com/silvermind/rack-utm
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.5.1
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Tracks parameters came via utm links.
|
146
|
+
test_files: []
|