Installing the snippet
Using npm (recommended)
Using the script tag
If you prefer not to use npm, add the script tag to yourindex.html:
Identifying users
Callchmln.identify once your user is authenticated. In SPAs, this is typically after login or when your auth state resolves:
Important: You only need to call chmln.identify once per session. Do not call it on every route change.
Handling route changes
Chameleon automatically detects URL changes in most SPAs. However, for the best experience, register a navigation handler so Chameleon can navigate your app programmatically (e.g., when a Tour button links to another page).React (with React Router v5)
React (with React Router v6+)
Vue (with Vue Router)
Angular
Generic (using History API)
If your SPA framework isn’t listed, use the browser’s History API:Clearing on logout
When a user logs out of your SPA (without a full page reload), callchmln.clear() to stop Chameleon from showing Experiences:
chmln.identify is called again.
Common SPA pitfalls
1. Callingidentify on every route change
Only call chmln.identify when the user identity is first established (e.g., after login or app load). Calling it on every route change is unnecessary and can cause issues.
2. Not registering the app:navigate handler
Without the navigation handler, Chameleon can’t programmatically route your app. Tour buttons that link to other pages will fall back to full page reloads.
3. Loading Chameleon before the user is known
Initialize with chmln.init() early, but don’t call chmln.identify until you have the user’s data. Chameleon won’t show Experiences to unidentified users.
4. Forgetting to clear on logout
If your SPA doesn’t reload on logout, the previous user’s Experiences may still show. Always call chmln.clear() on logout.
See also:
- JavaScript API Overview — full JS API reference
- Send user properties — detailed
chmln.identifyreference - Installing correctly — general installation best practices

