Skip to content

Commit 42ecb60

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 75f5cb1 commit 42ecb60

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
@@ -76,10 +76,17 @@
7676

7777
/* basic search bar */
7878
.search-form {
79-
background-color: #989898;
8079
margin-bottom: 0rem;
8180
padding: 2.4rem 2rem 1.6rem 2rem;
8281

82+
&.standard {
83+
background-color: #989898;
84+
}
85+
86+
&.alt {
87+
background-color: #ffd700;
88+
}
89+
8390
details {
8491
&:first-of-type {
8592
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
before_action :validate_geodistance_units!, only: %i[results]
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
@@ -1,4 +1,4 @@
1-
<form id="search-form" action="<%= results_path %>" method="get" role="search">
1+
<form id="search-form" class="<%= ab_test(:ui_colors, "standard", "alt") %>" action="<%= results_path %>" method="get" role="search">
22
<label for="basic-search-main">What can we help you find?</label>
33
<div class="form-wrapper">
44
<input id="basic-search-main" type="search" class="field field-text basic-search-input" name="q" title="Keyword anywhere" placeholder="Search for anything" value="<%= params[:q] %>" required>

0 commit comments

Comments
 (0)