Install Javascript Code Snippet

To launch Refiner surveys inside your application you need to install our JavaScript client snippet first. Installing the code snippet should only take a couple of minutes and you only need to do it once.

Quick installation

Copy & paste the code shown below into your applications HTML code, ideally just before the </body> tag.

<script async src=""></script>
window._refinerQueue = window._refinerQueue || [];
function _refiner(){_refinerQueue.push(arguments);}
_refiner('setProject', 'REFINER_PROJECT_ID');  

Once done, replace the static value ‘REFINER_PROJECT_ID’ with the identifier of your Refiner project. You can find the identifier in your Refiner dashboard under “Settings > Installation”.

If you are currently logged in to your dashboard, the identifier should have already been replaced for you.

That’s it! You are ready to launch surveys and call-to-actions for your users.

The code snippet above operates Refiner in the “anonymous visitor mode”. It means that no personal information about your users is shared with Refiner. Once the user fills out a survey, their answers are stored but without a specific identifier or email address.

To get the most out of Refiner, we highly recommend to identify logged in users though as shown in the next section.

Identify 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 Javascript client was loaded.

The identifyUser call expect a unique identifier (“user ID”) for each user. If you can’t provide a unique user ID for each user, please operate Refiner in anonymous visitor mode (see above).

The example from above then becomes:

<script async src=""></script>
window._refinerQueue = window._refinerQueue || [];
function _refiner(){_refinerQueue.push(arguments);}
_refiner('setProject', 'REFINER_PROJECT_ID');  // first we set the project ID
_refiner('identifyUser', {
  id: 'USER-ID-ABC-123', // The ID of your user
  email: '', // Provide their email address (optional)
  name: 'Jane Doe', // The full name of the user (optional)
Testing your Refiner installation

We recommend to always test your Refiner installation in a new “Incognito Window”. Our Javascript client leverages the local storage of your Browser to optimize its performance. Opening a new Incognito Window will ensure that you have a clean testing environment.

Advanced integration options

Our JavaScript client comes packed with advanced features that allow a seamless and deep integration with your SaaS application. You can continue exploring all options in our advanced JavaScript integration guide.

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