Install Refiner with our NPM Package

Our official NPM wrapper class provides a simple installation of the Refiner.io client through NPM.

The package automatically injects the Refiner.io JavaScript client and exports an object that wraps all client methods. All method calls are queued end executed once the Refiner.io JavaScript client is fully loaded.

Once installed, Popup Surveys and Call To Actions created through the Refiner dashboard are launched automatically according to their trigger configuration.

Installation

Our NPM package is installed in the same way you would install other packages. Navigate to the source code folder of your project and execute the following NPM installation command.

npm install refiner-js

Usage

Initialize client

The initialize the Refiner client you need to import our wrapper as shown below. This will give you a Refiner object which you can use to trigger all supported functions.

import _refiner from 'refiner-js';

_refiner('setProject', 'REFINER_PROJECT_ID');

Please make sure to replace the static value ‘REFINER_PROJECT_ID’ with your project ID. You can find your project ID in the your Refiner dashboard under “Settings > Installation”. In case you are connected to your Refiner dashboard right now, the code snippet above should already include your project ID.

That’s it! The Refiner JavaScript client is now loaded and communicating with the Refiner API. It’s time to identify your users.

Identify your users (recommended)

Refiner unleashes its full power when you identify your users and we highly recommend that you take the time to set up user identification.

Identifying your users allows you to better target specific accounts, sync survey responses with your user data, trigger user specific automations etc.

Identifying a user is easy with our Javascript client. All you need to do is to call a identifyUser method once our Javasript client was loaded.

_refiner('identifyUser', {
  id: 'USER-ID-ABC-123', // Each user needs an ID or email address
  email: 'jane@awesome.com', // Each user needs an ID or email address
  name: 'Jane Doe', // The full name of the user
});

Advanced integration options

Our NPM package provides advanced integration features allowing a seamless and deep integration with your SaaS application. You can continue exploring all options in our advanced JavaScript integration guide.