Installing using npm

Get Chameleon up and running on your website using NPM

Aaron Cody avatar
Written by Aaron Cody
Updated over a week 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.

Installing Chameleon via npm has 2 essential components:

  • installing the code snippet -- the Chameleon functionalities that allow you to create and publish Experiences

  • identifying users correctly -- the identification method that Chameleon uses to keep track of what to show to your users

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

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

The token above is an example, you can get your unique token from your installation page and replace the placeholder text with your own data.

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

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.

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).

To improve security and prevent impersonation, we strongly recommend using secure identity verification. It works by adding an encrypted user_hash (HMAC) to your installation snippet.

Keep in mind that your account will have secure identity verification enabled once your first verified request is received. Read more here.

Chameleon won’t accept sign-in requests without a valid user_hash. This user_hash is calculated using a secret key, by which Chameleon verifies the authenticity of requests made to our API.

⚠️ Your API 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.

You can verify your installation to make sure Chameleon has been successfully added to your domain or subdomain. Domains will show up automatically if data is being received. You can do this from the installation section of your Dashboard.

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. Check your Environments if you don't see it on this page. The same goes for new subdomains that you add to already-enabled domains.

This is to ensure better security and that no malicious domains get added to your account by default.

Learn more

Did this answer your question?