Attributes

Identifying Users

At Formbricks, we value user privacy. By default, Formbricks doesn't collect or store any personal information from your users. However, we understand that it can be helpful for you to know which user submitted the feedback and also functionality like recontacting users and controlling the waiting period between surveys requires identifying the users. That's why we provide a way for you to share existing user data from your app, so you can view it in our dashboard.

If you would like to use the User Identification feature of Formbricks, target surveys to specific user segments and see more information about the user who responded to a survey, you can identify users by setting a User ID, email, and custom attributes. This guide will walk you through how to do that.

Setting User ID

To enable the User identification feature you need to set the userId in the init() call of Formbricks. Only when the userId is set the person will be visible in the Formbricks dashboard. The userId can be any string and it's best to use the default identifier you use in your app (e.g. unique id from database or the email address if it's unique) but you can also anonymize these as long as they are unique for every user.

Setting User ID

formbricks.init({
  environmentId: "<environment-id>",
  apiHost: "<api-host>",
  userId: "<user_id>",
});

Enhanced Initialization with User Attributes

In addition to setting the userId, Formbricks allows you to set user attributes right at the initialization. This ensures that your user data is seamlessly integrated from the start. Here's how you can include user attributes in the init() function:

Enhanced Initialization with User Attributes

formbricks.init({
  environmentId: "<environment-id>",
  apiHost: "<api-host>",
  userId: "<user_id>",
  attributes: {
    // your custom attributes
    Plan: "premium",
  },
});

Setting User Email

The userId is the main identifier used in Formbricks and user identification is only enabled when it is set. In addition to the userId you can also set attributes that describes the user better. The email address can be set using the setEmail function:

Setting Email

formbricks.setEmail("user@example.com");

Setting Custom User Attributes

You can use the setAttribute function to set any custom attribute for the user (e.g. name, plan, etc.):

Setting Custom Attributes

formbricks.setAttribute("Plan", "free");

Logging Out Users

When a user logs out of your webpage, make sure to log them out of Formbricks as well. This will prevent new activity from being associated with an incorrect user. Use the logout function:

Logging out User

formbricks.logout();

Was this page helpful?