There are two components to this:
Using the JS API to send data to Chameleon, trigger Experiences, and tracking events.
Running JS code from any Chameleon Experience to create custom functionality.
The possibilities this opens are unlimited. For example, you could cause a Chameleon button to add focus to a specific input field in your app, can help your users take action in the right place to discover the value you are trying to demonstrate.
Using the JS API
This gives you the flexibility to incorporate Chameleon into key flows of your user journey, by making API calls either from your app or any other software on your stack.
One interesting use case could be, for example, to track an event every time a user opens a premium feature on your app, and then use this event to target these users for upsells. The API call would look like this:
chmln.track("Visited A/B Testing landing page");.
Running JS code from Chameleon Experiences
There are many examples of what you could execute, including:
Scrolling/focusing a user to a different place/element on the page.
Submitting some data to your systems (e.g. interest in a feature).
Opening up another in-product service (e.g. Zendesk chat window).
Giving a user a delightful surprise.
As mentioned before, you can run custom code from a Chameleon Button or from a Launcher Item; and both cases are equally easy to set up.
Triggering JS code from a Chameleon Button
To run code from a button, you'll need to leverage button actions. When the action is defined, the piece of code included will be run as soon as the button is clicked.
Triggering JS code from a Launcher Item
What code should I run?
alert("hello world!"); .
We have also written an article dedicated to showcasing common use cases for this feature, containing code examples.
Note: If you employ a Content Security Policy (CSP) then you must add an exception to allow this functionality to be used.