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. Templates receives the context as a local variable named experiment.
During Beta, Experiment Center runs on development tenants only. Production tenants are not supported.
Available context fields
The following fields are available in the page template 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 |
When no experiment is active, 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:
experiment.config.my_param.value → the parameter's value for this variation
Every parameter defined on the feature flag has a value in config. 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:
<%= experiment && experiment.config.heading_text.value %>
With a null check:
<% if (experiment) { %>
<h1><%= experiment.config.heading_text.value %></h1>
<% } else { %>
<h1>Create your account</h1>
<% } %>
Customize signup and login with Partials
When you customize Signup and Login prompts using partials, the experiment context is passed explicitly as part of your partial.
In the partial, the same experiment variable is available:
<!-- partials/signup-header.ejs -->
<header>
<h1>
<% if (experiment && experiment.config.heading_text) { %>
<%= experiment.config.heading_text.value %>
<% } else { %>
Create your account
<% } %>
</h1>
</header>
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": {
"type": "string",
"value": "Create your account",
"description": "Headline text on the signup screen"
}
}
Control variation: empty overrides (inherits signup_headline: "Create your account")
Treatment variation:
{
"overrides": {
"signup_headline": { "value": "Join in seconds" }
}
}
Template code:
<!-- signup.ejs -->
<div class="signup-container">
<h1>
<% if (experiment) { %>
<%= experiment.config.signup_headline.value %>
<% } else { %>
Create your account
<% } %>
</h1>
{%- auth0:widget -%}
</div>
Users assigned to the control variation see “Create your account.” Users in the treatment see “Join in seconds.” Users with no active experiment also see “Create your account” (the else branch).
Example: conditional UI element
This example uses a boolean parameter to show or hide an additional UI element:
<!-- login.ejs -->
<% if (experiment && experiment.config.show_social_proof.value === true) { %>
<div class="social-proof">
<p>Join 2 million people who sign in with their passkey.</p>
</div>
<% } %>
{%- auth0:widget -%}
The === 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:
<h1>
<%= (experiment && experiment.config.page_title && experiment.config.page_title.value)
|| "Default page title" %>
</h1>
Or use explicit if/else blocks (more readable for complex conditions):
<% if (experiment && experiment.config.page_title) { %>
<h1><%= experiment.config.page_title.value %></h1>
<% } else { %>
<h1>Default page title</h1>
<% } %>
Hardcode the fallback values in your templates. They match the control variation’s baseline, so your templates behave correctly both when no experiment is running and when the control variation is assigned.