Documentation Index
Fetch the complete documentation index at: https://docs.kameleoon.com/llms.txt
Use this file to discover all available pages before exploring further.
Use client-side SDKs corresponding to the preferred framework to run experiments or feature flags. If the Feature Experimentation module is unavailable or if SDK installation is not desired, follow the workaround described in this article to run experiments using the Activation API.
Context
Modern JavaScript client-side frameworks (React, Angular, Vue, etc.) manage the DOM tree and elements (often implementing a virtual DOM). This internal management makes implementing client-side tests difficult outside of the specific framework because DOM manipulations conflict with framework behavior. External modifications to elements or logic are often overwritten. Workarounds exist for these issues, such as using DOM Mutation Observers, but external code must handle these carefully. Rather than using an intrusive external approach, implement variations directly in the existing React, Angular, or Vue codebase and trigger experiments programmatically. This logic mirrors SDK usage—the Kameleoon frontend engine serves as the equivalent of the JavaScript SDK.Techniques described in this article require redeploying the JS source code to launch experiments or personalizations. While this approach simplifies coding, it lacks the flexibility of standard Kameleoon methodologies that allow launches without IT deployments. A developer with repository access must perform the implementation.External implementation of JS experiments (via Kameleoon’s injected code) or a combination of both approaches remains possible.
The installation process matches that of a standard website—add an external JavaScript application file containing the Kameleoon engine and the Activation API.
Creation and configuration of the experiment
The steps match those of standard A/B experiments (variation creation, goal selection, and analytics integration). Note the following requirements:- Create an experiment using the code editor.
- Select the Explicit trigger targeting condition to trigger the experiment manually via the API.
Leave the JS code for variations empty in most cases. However, including JSON data in variations is useful for retrieving parameters in application code; these parameters can be updated in the Kameleoon interface without requiring further redeployments.
Sample Code to trigger an experiment
The code sample below demonstrates how to trigger an experiment and obtain the associated variation for the current user.Kameleoon.API.Experiments.getAll() does not include experiments that are not launched via the interface. This setup allows for preparing code deployments and launching experiments independently—typically, IT teams plan deployments while product owners schedule launches.