Ruby on Rails Experiments installation
- 1
Install the gems
RequiredAdd the
posthog-rubyandposthog-railsgems to your Gemfile:GemfileThen run:
Terminal - 2
Generate the initializer
RequiredRun the install generator to create the PostHog initializer:
TerminalThis will create
config/initializers/posthog.rbwith sensible defaults and documentation. - 3
Configure PostHog
RequiredUpdate
config/initializers/posthog.rbwith your project token and host:config/initializers/posthog.rb - 4
Implement your experiment
RequiredExperiments run on top of our feature flags. You can define which version of your code runs based on the return value of the feature flag:
Note: Server-side experiment metrics require you to manually send the feature flag information. See this tutorial for more information.
- 5
Run your experiment
RequiredOnce you've implemented the feature flag in your code, you'll enable it for a target audience by creating a new experiment in the PostHog dashboard.
- 6
Next steps
RecommendedNow that you're running experiments, continue with the resources below to learn what else Experiments enables within the PostHog platform.
Resource Description Creating an experiment How to create an experiment in PostHog Adding experiment code How to implement experiments for all platforms Statistical significance Understanding when results are meaningful Experiment insights How to analyze your experiment data More tutorials Other real-world examples and use cases