App Surveys

User Identification

User Identification helps you to not only segment your users but also to see more information about the user who responded to a survey. This helps you to target surveys to specific user segments and see more information about the user who responded to a survey.

Understanding Identified vs Unidentified Users

In Formbricks, understanding the distinction between identified and unidentified users is crucial for effective survey segmentation and targeted feedback collection.

FeatureUnidentified UsersIdentified Users
Show surveys based on trigger actions
Set recontact details to avoid survey fatique
Target a subset of users using attributes & segments
Collect user information in Formbricks
Track custom attributes
Counts towards your monthly tacked user (MTU) limit
Recommended for public-facing websites
Recommended for web apps after login

Identified Users

Identified users are those for whom specific information has been set, notably the userId. This identification allows for more precise targeting of surveys and a deeper understanding of the feedback provided. When enabled, all information specified by you and all actions are sent to Formbricks.

This method is recommended for applications where users are required to log in and will often return.

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 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");

Generally speaking, the setAttribute function works like this:

Setting Custom Attributes

formbricks.setAttribute("attribute_key", "attribute_value");

Where attributeName is the name of the attribute you want to set, and attributeValue is the value of the attribute you want to set.

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?