optimize_ab 0.0.9 → 0.0.10
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.
- data/README.md +59 -17
- data/lib/optimize_ab/helpers.rb +5 -76
- data/lib/optimize_ab/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,29 +1,71 @@
|
|
1
|
-
|
1
|
+
How to use Optimize_AB
|
2
|
+
---------------------------------------
|
3
|
+
Taken from but altered slightly:
|
4
|
+
http://support.google.com/websiteoptimizer/bin/static.py?hl=en&topic=29622&guide=29619&page=guide.cs#m2
|
2
5
|
|
3
|
-
TODO: Write a gem description
|
4
6
|
|
5
|
-
|
7
|
+
Multi-Variate Control & Tracking Script
|
8
|
+
---------------------------------------
|
9
|
+
The control script goes on your test page and makes sure that
|
10
|
+
the experiment variations are switched randomly and that all
|
11
|
+
variations are displayed an equal number of times.
|
6
12
|
|
7
|
-
|
13
|
+
The tracking script goes on your test page ensures that visits
|
14
|
+
to the page are recorded in the experiment.
|
8
15
|
|
9
|
-
|
16
|
+
The control script immediately after the <head> tag.
|
10
17
|
|
11
|
-
|
18
|
+
mv_head(k, ua, pv)
|
12
19
|
|
13
|
-
|
20
|
+
Arguements can be taken directly form the Google Optimize Website Script code
|
14
21
|
|
15
|
-
Or install it yourself as:
|
16
22
|
|
17
|
-
|
23
|
+
Multi-Variate Page Sections Scripts
|
24
|
+
---------------------------------------
|
25
|
+
The page sections script is used to mark
|
26
|
+
the elements that will be varied during the experiment.
|
27
|
+
Essentially, you need to use the script provided by Website
|
28
|
+
Optimizer to define the beginning and end of each element. For
|
29
|
+
each element, you will need to name the page section in the script.
|
30
|
+
As an example, let's say you defined a header that welcomes
|
31
|
+
people to your page. The starting HTML code looks like this:
|
18
32
|
|
19
|
-
|
33
|
+
<h1>Welcome!</h1>
|
20
34
|
|
21
|
-
|
35
|
+
After adding your section script, the header will look like this
|
36
|
+
(with the custom name "Headline" for this section in italics):
|
37
|
+
|
38
|
+
<h1>
|
39
|
+
<%= mv_begin_section("Headline") %>
|
40
|
+
Welcome!
|
41
|
+
<%= mv_end_section %>
|
42
|
+
</h1>
|
43
|
+
|
44
|
+
in HAML a link might be written as:
|
45
|
+
|
46
|
+
= link_to (mv_begin_section('Headline') + "Welcome" + mv_end_section)
|
47
|
+
|
48
|
+
|
49
|
+
OnClick Conversion
|
50
|
+
---------------------------------------
|
51
|
+
You'll need to add a snippet of text to the link or links
|
52
|
+
that you want to track as a conversion. Let's say your link
|
53
|
+
looks like this:
|
54
|
+
|
55
|
+
<a href="http://www.example.com/promotion">Featured Products</a>
|
56
|
+
|
57
|
+
To count a conversion when this link is clicked, add:
|
58
|
+
|
59
|
+
onclick="doGoal(this);return false;"
|
60
|
+
|
61
|
+
to the HTML tag. The new link will look like this
|
62
|
+
(addition in bold):
|
63
|
+
|
64
|
+
<a href="http://www.example.com/promotion" onclick="doGoal(this);return false;">Featured Products</a>
|
65
|
+
|
66
|
+
You can modify as many links as you want to count as a conversion,
|
67
|
+
but all of them will be counted identically as conversions in your
|
68
|
+
experiment results. In other words, Website Optimizer will not
|
69
|
+
differentiate between them when reporting conversions.
|
22
70
|
|
23
|
-
## Contributing
|
24
71
|
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
data/lib/optimize_ab/helpers.rb
CHANGED
@@ -1,79 +1,8 @@
|
|
1
1
|
module Helpers
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
# How to use Optimize_AB
|
6
|
-
# ---------------------------------------
|
7
|
-
# Taken from but altered slightly:
|
8
|
-
# http://support.google.com/websiteoptimizer/bin/static.py?hl=en&topic=29622&guide=29619&page=guide.cs#m2
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# Multi-Variate Control & Tracking Script
|
12
|
-
# ---------------------------------------
|
13
|
-
# The control script goes on your test page and makes sure that
|
14
|
-
# the experiment variations are switched randomly and that all
|
15
|
-
# variations are displayed an equal number of times.
|
16
|
-
#
|
17
|
-
# The tracking script goes on your test page ensures that visits
|
18
|
-
# to the page are recorded in the experiment.
|
19
|
-
#
|
20
|
-
# The control script immediately after the <head> tag.
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# Page Sections Scripts
|
24
|
-
# ---------------------------------------
|
25
|
-
# The page sections script is used to mark
|
26
|
-
# the elements that will be varied during the experiment.
|
27
|
-
# Essentially, you need to use the script provided by Website
|
28
|
-
# Optimizer to define the beginning and end of each element. For
|
29
|
-
# each element, you will need to name the page section in the script.
|
30
|
-
# As an example, let's say you defined a header that welcomes
|
31
|
-
# people to your page. The starting HTML code looks like this:
|
32
|
-
#
|
33
|
-
# <h1>Welcome!</h1>
|
34
|
-
#
|
35
|
-
# After adding your section script, the header will look like this
|
36
|
-
# (with the custom name "Headline" for this section in italics):
|
37
|
-
#
|
38
|
-
# <h1>
|
39
|
-
# <%= multi_begin_section("Headline") %>
|
40
|
-
# Welcome!
|
41
|
-
# <%= multi_end_section %>
|
42
|
-
# </h1>
|
43
|
-
#
|
44
|
-
# in HAML a link might be written as:
|
45
|
-
#
|
46
|
-
# = link_to (multi_begin_section('Headline') + "Welcome" + multi_end_section)
|
47
|
-
#
|
48
|
-
#
|
49
|
-
# OnClick Conversion
|
50
|
-
# ---------------------------------------
|
51
|
-
# You'll need to add a snippet of text to the link or links
|
52
|
-
# that you want to track as a conversion. Let's say your link
|
53
|
-
# looks like this:
|
54
|
-
#
|
55
|
-
# <a href="http://www.example.com/promotion">Featured Products</a>
|
56
|
-
#
|
57
|
-
# To count a conversion when this link is clicked, add:
|
58
|
-
#
|
59
|
-
# onclick="doGoal(this);return false;"
|
60
|
-
#
|
61
|
-
# to the HTML tag. The new link will look like this
|
62
|
-
# (addition in bold):
|
63
|
-
#
|
64
|
-
# <a href="http://www.example.com/promotion" onclick="doGoal(this);return false;">Featured Products</a>
|
65
|
-
#
|
66
|
-
# You can modify as many links as you want to count as a conversion,
|
67
|
-
# but all of them will be counted identically as conversions in your
|
68
|
-
# experiment results. In other words, Website Optimizer will not
|
69
|
-
# differentiate between them when reporting conversions.
|
70
|
-
#
|
71
|
-
####################################################################
|
3
|
+
######## Multi-Variate Control / Tracking Script / Click Function ########
|
72
4
|
|
73
|
-
|
74
|
-
######## Control / Tracking Script / Click Function ########
|
75
|
-
|
76
|
-
def ab_head(k, ua, pv)
|
5
|
+
def mv_head(k, ua, pv)
|
77
6
|
js = <<-HTML
|
78
7
|
<script>
|
79
8
|
function utmx_section(){}function utmx(){}
|
@@ -108,16 +37,16 @@ module Helpers
|
|
108
37
|
end
|
109
38
|
|
110
39
|
|
111
|
-
######## Page Sections Scripts ########
|
40
|
+
######## Multi-Variate Page Sections Scripts ########
|
112
41
|
|
113
|
-
def
|
42
|
+
def mv_begin_section(name)
|
114
43
|
js = <<-HTML
|
115
44
|
<script>utmx_section("#{name}")</script>
|
116
45
|
HTML
|
117
46
|
return js.html_safe
|
118
47
|
end
|
119
48
|
|
120
|
-
def
|
49
|
+
def mv_end_section
|
121
50
|
js = <<-HTML
|
122
51
|
</noscript>
|
123
52
|
HTML
|
data/lib/optimize_ab/version.rb
CHANGED