Skip to content

Commit 9e9ae0e

Browse files
Implement a first experiment
This sets up a simple UI experiment, defining an alternative set of styles for the search form. The search form starts in the _form.html.erb partial, with most users getting a "standard" class - the experimental group would get the "alt" class, which is rendered differently. The experiment ends when a user reaches a search results page (i.e, they submitted the form and thus got results). Curious folks can force themselves into one or the other pool by using a querystring such as ?ab_test[ui_colors]=alt or ?ab_test[ui_colors]=standard
1 parent feea276 commit 9e9ae0e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

app/assets/stylesheets/partials/_search.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44

55
/* basic search bar */
66
.basic-search {
7-
background-color: #989898;
87
margin-bottom: 0rem;
98
padding: 2.4rem 2rem 1.6rem 2rem;
109

10+
&.standard {
11+
background-color: #989898;
12+
}
13+
14+
&.alt {
15+
background-color: #ffd700;
16+
}
17+
1118
details {
1219
&:first-of-type {
1320
margin-top: 1rem;

app/controllers/search_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class SearchController < ApplicationController
1212
end
1313

1414
def results
15+
# if we are loading results, the user submitted the form - so this experiment is finished
16+
ab_finished(:ui_colors)
17+
18+
# ab_test(:result_format)
19+
1520
# inject session preference for boolean type if it is present
1621
params[:booleanType] = cookies[:boolean_type] || 'AND'
1722

app/views/search/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if params[:geodistance] == "true"
2525
end
2626
%>
2727

28-
<form id="basic-search" class="form-horizontal basic-search" action="<%= results_path %>" method="get" role="search">
28+
<form id="basic-search" class="form-horizontal basic-search <%= ab_test(:ui_colors, "standard", "alt") %>" action="<%= results_path %>" method="get" role="search">
2929
<div class="form-group">
3030
<input id="basic-search-main" type="search"
3131
class="field field-text basic-search-input <%= "required" if search_required %>" name="q"

0 commit comments

Comments
 (0)