![Use a `.gitlab-ci.yml` template](img/add_file_template_11_10.png)
While building your `.gitlab-ci.yml`, you can use the [CI/CD configuration visualization](yaml/visualization.md) to facilate your writing experience.
While building your `.gitlab-ci.yml`, you can use the [CI/CD configuration visualization](yaml/visualization.md) to facilitate your writing experience.
For a broader overview, see the [CI/CD getting started](quick_start/README.md) guide.
Experiments can be performed on a `subject`. The `subject` that gets provided needs to respond to `to_global_id` or `to_s`.
The resulting string is bucketed and assigned to either the control or the experimental group. It's therefore necessary to always provide the same `subject` for an experiment to have the same experience.
- Use this standard for the experiment in a controller:
```ruby
class RegistrationController < ApplicationController
Experiment run for a user:
```ruby
class ProjectController < ApplicationController
def show
# experiment_enabled?(:experiment_key) is also available in views and helpers
if experiment_enabled?(:signup_flow, subject: current_user)
# render the experiment
else
# render the original version
end
end
end
```
or experiment run for a namespace:
```ruby
if experiment_enabled?(:signup_flow, subject: namespace)
# experiment code
else
# control code
end
```
When no subject is given, it falls back to a cookie that gets set and is consistent until
the cookie gets deleted.
```ruby
class RegistrationController < ApplicationController
def show
# falls back to a cookie
if experiment_enabled?(:signup_flow)
# render the experiment
else
# render the original version
end
end
end
```
end
```
- Make the experiment available to the frontend in a controller:
@@ -255,7 +286,7 @@ Along with the tracking of backend and frontend events and the [recording of exp
-**Experimental experience:** Show an in-product nudge to see if it causes more people to sign up for trials.
-**Conversion event:** The user starts a trial.
The `record_experiment_conversion_event` helper method is available to all controllers, and enables us to easily record the conversion event for the current user, regardless of whether they are in the control or experimental group:
The `record_experiment_conversion_event` helper method is available to all controllers. It enables us to record the conversion event for the current user, regardless of whether they are in the control or experimental group:
```ruby
before_actiondo
...
...
@@ -296,7 +327,7 @@ context 'when the experiment is active' do
context'when the user is in the experimental group'do
beforedo
stub_experiment_for_user(signup_flow: true)
stub_experiment_for_subject(signup_flow: true)
end
it{is_expected.todo_experimental_thing}
...
...
@@ -304,7 +335,7 @@ context 'when the experiment is active' do