Skip to main content

Documentation 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.

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 through 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:
VariableTypeDescription
experiment.experiment_idstringThe active experiment ID
experiment.variation_idstringThe assigned variation ID
experiment.configobjectMerged configuration: baseline parameters + variation overrides
experiment.is_controlbooleanWhether 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. 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:
<%= 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>
<% } %>

Auth0 Partials

When you use partials (sub-templates included from a main template), you pass the experiment context to the partial explicitly:
<%- include('partials/signup-header', { experiment: experiment }) %>
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>

  <form action="/usernamepassword/login" method="POST">
    <!-- form fields -->
  </form>
</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>
<% } %>

<form action="/usernamepassword/login" method="POST">
  <!-- form fields -->
</form>
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.