When an experiment is active and a variation is assigned, the Experiment Center injects experiment context into the page template rendering context automatically. Page templates do not require an opt-in step: experiment context is passed to all templates unconditionally when an experiment is active. Experiment context is registered as a Universal Login state property and is passed to your template throughDocumentation Index
Fetch the complete documentation index at: https://auth0-feat-experiment-center.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
renderLocals. Your template receives it as a local variable.
Available context fields
The following fields are available in the template rendering context when an experiment is active:| Variable | Type | Description |
|---|---|---|
experiment.experiment_id | string | The active experiment ID |
experiment.variation_id | string | The assigned variation ID |
experiment.config | object | Merged configuration: baseline parameters + variation overrides |
experiment.is_control | boolean | Whether this is the control variation |
experiment is null (or not present). Always null-check before using.
experiment.config structure
experiment.config is a key/value map where each key is a parameter name and each value is an object with a value property:
config. The Experiment Center merges the baseline parameters with the variation’s overrides before injection, so you never need to look up the default yourself.
Read a parameter in a template
Auth0 Universal Login page templates use EJS. The examples below use EJS syntax. EJS syntax:Auth0 Partials
When you use partials (sub-templates included from a main template), you pass the experiment context to the partial explicitly:experiment variable is available:
Example: signup headline copy variant
This example shows a feature flag with a string parameter that controls the signup page headline. The control variation uses “Create your account”; the treatment uses “Join in seconds.” Feature flag parameters:signup_headline: "Create your account")
Treatment variation:
Example: conditional UI element
This example uses a boolean parameter to show or hide an additional UI element:=== true comparison (rather than a truthy check) prevents the element from appearing when experiment is null or when the parameter is absent.
Safe defaults when no experiment is active
When no experiment is active,experiment is null in the template context. Structure your templates to always render correctly without experiment context: