Skip to main content
Installing using npm

Get Chameleon up and running on your website using NPM

Tiago Mota avatar
Written by Tiago Mota
Updated over 7 months ago

Npm is a node JS package manager that allows you to install all dependencies needed into your project. Chameleon is available as an npm package that you can easily install by first running the install script in a front-end packager like Browserify or Webpack.

We recommend using npm if you are working with Node.js and other front-end frameworks such as React JS, Vue.js, and AngularJS.

🧑‍💻 Ask your developer to help you if you're not comfortable installing Chameleon this way.


Install Chameleon via npm

Installing Chameleon via npm has 2 essential components:

  • installing the code snippet (the Chameleon functionalities that allow you to create and publish Experiences) and identifying users correctly (using the identification method that Chameleon uses to keep track of what to show to your users).

  • sending user data for targeting and personalization (such as user or company properties, and user events)

Optionally, you can also Encode your UIDs to prevent unauthorized access to your data. This is a step you can take during your npm installation.

Head over to the installation page in your Dashboard, select “Install via NPM” as your installation method, and follow these steps.

Install the Chameleon snippet and identify your users

First, run the script from your Dashboard to install Chameleon into a project using a front-end bundler like Browserify or Webpack. You can then require the library like a standard Node.js module.

You'll identify your users by sending a unique ID to Chameleon. This step is essential in displaying Experiences to your users.

Encode your UIDs

This step is optional, but highly recommended.

Next, you can Encode your user IDs by leveraging the Secret Key that Chameleon provides on the installation page. This works by adding an encrypted user_hash (HMAC) to your installation snippet. Once you enable this, Chameleon won’t accept sign-in requests without a valid user_hash and verifies the authenticity of requests made to our API.

From the dropdown, you can pick the server side language you are using and simply insert your Secret Key into the code snippet that Chameleon generates.

Make sure to use the Secret Key from the installation page to successfully Encode our user IDs.

Your Secret Key should not be shared with anyone, please add it as an environment variable on the backend responsible for generating this hash. If a third party gains access to this key, this secure method would be compromised. If needed, contact us to rotate your secret.

Send data to Chameleon

To get the most value out of Chameleon - creating target audiences, and segmenting users - you should send additional user or company data so you can target Experiences to the right users.

Pick what data to send to Chameleon by copying the snippets for user properties, company properties, or user events. You can use our JS API and our REST API to achieve this.

Verify and finish your installation

The last step is to verify that Chameleon has been successfully added to your domains or subdomains and finish your installation. Domains will show up automatically if data is being received here but you can also enable additional domains.


If you install Chameleon on a domain that's different from your email domain, it will be automatically disabled, and you should manually enable it from the "Verify Installation" page or from your Environments. The same goes for new subdomains that you add to already-enabled domains, to ensure better security and that no malicious domains get added to your account by default. ​

Chameleon must be installed and be able to identify users on every page that you want Experiences to display (not just when users log in).

Did this answer your question?