Copy & Paste 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. A detailed comparison of the two modes can be found here.

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: '', // 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.

_refiner('identifyUser', {
    id: 'USER-ID-ABC-123', // Replace with your user ID
    email: '', // Replace with user Email
    name: 'Jane Doe', // Replace with user name
    plan: 'free',
    locale: 'en_US',
    a_date: '2021-12-12',
    a_number: 42,
    something_else: 'wagmi'

Next to identifying your users, our JavaScript provides various advanced features that allow a seamless and deep integration with your SaaS application.

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

Explore all options

Once you’ve installed our JavaScript client successfully, it’s time explore all options and methods that are available. Please continue exploring all options in our Client Reference.

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