diff --git a/EXAMPLES.md b/EXAMPLES.md index 8704ae4a..f584f7e2 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -11,6 +11,7 @@ Each topic lives in its own file under [`examples/`](examples). - [Ephemeral Browsing](examples/ephemeral-browsing.md) - [Auth Tab](examples/auth-tab.md) - [DPoP](examples/dpop.md) +- [Experiment Center](examples/experiment-center.md) - [Handling Configuration Changes During Authentication](examples/configuration-changes.md) ## Authentication API diff --git a/examples/experiment-center.md b/examples/experiment-center.md new file mode 100644 index 00000000..faa2d3eb --- /dev/null +++ b/examples/experiment-center.md @@ -0,0 +1,89 @@ +# Experiment Center + +[Experiment Center](https://auth0.com/docs/customize/experiment-center/overview) is Auth0's A/B testing platform for authentication flows. It lets you split traffic across variants, measure results, and promote the winner — all inside Auth0. + +Pass `experiment_id` and `variation_id` via `withParameters()` to force a user into a specific variation for the login request, bypassing the server-side deterministic assignment. Both IDs are obtained from your Auth0 Dashboard or the Management API. + +```kotlin +WebAuthProvider.login(account) + .withParameters(mapOf( + "experiment_id" to "", + "variation_id" to "" + )) + .start(this, callback) +``` + +
+ Using coroutines + +```kotlin +WebAuthProvider.login(account) + .withParameters(mapOf( + "experiment_id" to "", + "variation_id" to "" + )) + .await(this) +``` + +
+ +
+ Using Java + +```java +WebAuthProvider.login(account) + .withParameters(new HashMap() {{ + put("experiment_id", ""); + put("variation_id", ""); + }}) + .start(this, callback); +``` + +
+ +When the experiment uses segment targeting, also pass `segment_id`: + +```kotlin +WebAuthProvider.login(account) + .withParameters(mapOf( + "experiment_id" to "", + "variation_id" to "", + "segment_id" to "" + )) + .start(this, callback) +``` + +
+ Using coroutines + +```kotlin +WebAuthProvider.login(account) + .withParameters(mapOf( + "experiment_id" to "", + "variation_id" to "", + "segment_id" to "" + )) + .await(this) +``` + +
+ +
+ Using Java + +```java +WebAuthProvider.login(account) + .withParameters(new HashMap() {{ + put("experiment_id", ""); + put("variation_id", ""); + put("segment_id", ""); + }}) + .start(this, callback); +``` + +
+ +> [!NOTE] +> Experiment Center is an Enterprise feature. The override only applies to the current request — the next login without these parameters reverts to server-side deterministic assignment. Refer to the [Experiment Center documentation](https://auth0.com/docs/customize/experiment-center/overview) for setup instructions. +> +> Only `WebAuthProvider` login reaches Experiment Center. Embedded/native login and ROPG skip `/authorize` entirely and do not support experiment overrides.