Install JavaScript SDK
JavaScript SDK
1
Install the SDK
Below is the Specific tag. Copy and paste it in the code of every page of your website or web app, where you want Specific to track your users. Paste it immediately after the <head> element. Don’t add more than one Specific tag to each page.
Be sure to replace your ID in the last line. You can copy the entire snippet from the JS SDK integration section in your workspace.
2
Identify users
This is important if you want to know who said what; otherwise, all responses will remain anonymous.
When a user visits a page with our SDK, they receive a unique visitor ID that enables targeted surveys. However, users remain unauthenticated until their visitor IDs align with the unique User IDs in your system.
If you are already using IDs in your system, we recommend to sync IDs across platforms for consistent targeting and prevent repeating surveys.
Requirements for IDs:
Unique: No two users share the same ID.
Mappable: IDs link back to your internal system.
Static: IDs remain the same over time.
Set User ID
Use setUserId to assign a user’s identifier (up to 256 characters) upon login. This function is safe to call multiple times and ensures user identification consistency across sessions.
Logout
When a user logs out of your site or product, be sure to log them out from our system as well. This prevents any new actions from being mistakenly attributed to the wrong user. Keep in mind that if you use this for an unauthenticated user, a new ID will be created and counted separately toward your user limit.
3
Track an Event to trigger surveys
Events are used to trigger surveys or target specific users based on their actions within your product. By tracking events, you can ensure surveys are displayed at the right moment and to the right audience.
Types of Events
Our platform supports two types of events for triggering and filtering surveys:
No-Code Events: These events can be set up by team members without accessing the codebase, making them ideal for quick updates or experiments. No-Code events can be configured later using our intuitive interface.
Code Events: These events require a developer to implement tracking directly in your codebase. They are highly customizable and can include additional properties for more detailed targeting or behavior.
Setting Up No-Code Events
No-Code Events can be configured directly through the Events Interface without modifying your application’s code. This allows your non-technical team members to quickly define and manage events for triggering surveys.
Implementing Code Events
To track a Code Event, you can use the following snippet in your application. This tracks the event in the background:
If you want the event to trigger a survey immediately (e.g., opening a modal after a user clicks a button), use this enhanced snippet. It provides instant feedback without waiting for a server response:
4
Track Attributes to target Users
Attributes let you achieve two key goals: gain more context about your users and target surveys more effectively.
By adding data about your users, you can see who provided each response, making conversations identifiable instead of anonymous.
When it comes to targeting, attributes allow you to narrow your focus. For instance, you can display surveys only to specific user segments, such as power users or users in a particular country. Additionally, attributes make it easier to filter and analyze survey responses.
Name, Email
Use setName and setEmail to assign a user's name and email address.
Custom Attributes
Use setAttributes or setAttribute to add any custom attribute, such as the user's country or whether they are a power user.
Language
If your product's UI supports multiple languages, you can survey users in their native language. Use setLanguage with an ISO 639-1 language code (see the list of language codes) to set the user's preferred language.
5
Group Users
Use the setGroup function to organize your users into meaningful groups, such as companies or workspaces (e.g., workspaces in Figma). This function assigns a user to a specific group—like a Company or Workspace ID—at login, ensuring consistent group tracking across sessions. Each group ID can be up to 256 characters.
Key Recommendations:
Placement: You can include this code snippet anywhere in your application, though it is typically added near the setUserId function during user sign-up or login.
Uniqueness: Ensure GROUP_ID is a unique identifier, ideally the workspace or company ID from your database.
Attributes: Include the company's name and any additional attributes (e.g., subscription_plan, company_size) to enhance filtering and reporting capabilities.
Limitations: A user can belong to only one group at a time.
Grouping users allows you to analyze conversations, filter reports, and target surveys more effectively.
You can do more using our public API. Learn more in our API documentation.