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.

Get the Javascript code snippet

Go to your Refiner project and locate our code snippet under SETTINGS > INSTALL REFINER CLIENT. Copy the code and paste it into the HTML of your web-app, ideally right before the closing </BODY> tag.

Identify your users

While you can operate Refiner without disclosing any information about your users, we highly recommend to identify them whenever possible.

Identifying your users allows you to link survey responses to a user of your SaaS app. It will also allow you to better segment and target them, as well as syncing survey responses with other systems.

The following code block is responsible for identifying your users. Make sure to replace the static values from the code sample with real dynamic user data.

_refiner('identifyUser', {
    id: 'USER-ID-ABC-123', // Replace with your user ID
    email: 'jane@awesome.com', // Replace with user Email
    name: 'Jane Doe', // Replace with user name
});

To identify your users, you need to at least provide a unique ID of the currently logged-in user.

Next to a unique User ID, you can provide any kind of user traits. For example the email address of your user, their name, but also traits like their subscription plan, their country, etc.

Operate client in Anonymous Mode

Refiner was built primarily to survey identified users. There are however situations where you can’t or don’t want to identify your users. For example if you want to survey anonymous website traffic.

Operating our survey widget in Anonymous Mode 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.

You can switch between the two modes in the bottom of the code editor as shown below.

If this is the case, you need to remove the identifyUser call from the code snippet as shown below.

Important: When using the Anonymous Mode, please make sure that the distribution channel of your survey is set to “Website Popup Survey”.

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.

Testing your Refiner installation

We recommend to always test your Refiner installation locally or on a staging server before deploying it in production environment. Our JavaScript client comes with a built-in Debug Mode that will help you track down issues quickly.

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