Install Refiner with NPM

Our official NPM package provides a simple way to install the Refiner client in your Javascript application.

The package automatically injects the JavaScript client and exports an object that wraps all client methods. All method calls are queued and executed once the 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.

Install NPM package

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

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: '', // Each user needs an ID or email address
  name: 'Jane Doe', // The full name of the user

Discover all options

Once your NPM package installation is working, it’s time to discover all options and methods that the Refiner client exposes for a seamless and deep integration with your SaaS application. You can continue exploring all options in our Client Reference.

Was this helpful? Let us know with a quick a vote