---
title: "Adding Custom Properties and Events for User Tracking"
description: "Summary"
canonical_url: "https://help.brainfi.sh/articles/adding-custom-properties-and-events-for-user-tracking-nF4z8Izwp7"
md_url: "https://help.brainfi.sh/articles/adding-custom-properties-and-events-for-user-tracking-nF4z8Izwp7.md"
---
# Adding Custom Properties and Events for User Tracking

## Summary

Learn how to enrich user profiles by injecting custom attributes and sending events. This powerful feature provides deeper insights into user characteristics and their behavior within your application.

## When to Use This

This functionality is ideal when you need to segment users based on specific criteria or understand the context of their questions. Track custom properties like subscription plans or user roles, and send events to record key actions, such as reaching a certain stage in an application.

## Detailed Explanation

### Injecting Custom Attributes

To effectively enrich user profiles, it is crucial to understand which fields are required and how optional fields can enhance the user tracking experience.

The **required fields** for the `identify` call are:

* **userId**: A unique identifier for the user (e.g., their database ID or email).

Other fields that help identify the user properly:

* **email**: The user's email address for additional context.
* **phone**: The user's phone number in E.164 format.

Other extra information about the user should be placed in:

* **properties**: This is where you add custom attributes to further enrich the user profile.

It’s important to note that failing to place extra attributes inside the `properties` object may lead to a lack of personalization for the user. Properly categorizing users with these additional attributes enables more targeted insights and enhances your ability to address their specific needs.

By adding custom attributes, you can get more details about the characteristics of your users. This allows you to categorize users and analyze their behavior based on different segments.

For example, you can track:

* *Subscription Tier*: Differentiate between 'free' and 'premium' users.
* *User Role*: Identify if a user is an 'admin' or a standard user.
* *Team Information*: Group users by their `teamId`.
* *Custom Tags*: Apply any internal customer category tagging you use.

These attributes are added inside the `properties` object of the `identify` call.

```javascript
window.BrainfishAnalytics("identify", {
  userId: user.id,       // Required: A unique identifier for the user (e.g., their database ID).
  email: user.email,     // Optional: The user's email address for additional context.
  phone: user.phone,     // Optional: The user's phone number in E.164 format
  properties: {          // Optional: Custom attributes to enrich the user profile. You can add anything here. The following are examples.
    teamId: user.teamId,           // The team or organization the user belongs to.
    subscription: user.subscription, // The user's subscription level or plan.
    isAdmin: user.isAdmin,         // A boolean indicating if the user is an admin.
  },
});
```

### Sending Events

You can also send events to describe what a user is doing or what stage of your application they are in. This helps in understanding the context behind a user's question. For instance, you could send an event when a user navigates to a specific page or completes a certain action.

## Examples and Use Cases

* **Personalized Answers**: By identifying a user's subscription level, you could tailor the answers they receive to be more specific to the features available to them.
* **Behavioral Analysis**: If you tag users by their role (e.g., 'admin'), you can analyze if admins ask different types of questions compared to regular users. This can help you create more relevant documentation for each user group.
* **Contextual Support**: Sending an event when a user is on a particular page (e.g., the billing page) gives you context if they ask a question, allowing for a more efficient and accurate response.

## Common Questions (FAQs)

**Where can I see the custom properties and events?** This data will be available in your analytics dashboard, where you can filter and segment users based on the custom attributes you have passed.

**Is there a limit to the number of custom properties I can add?** While generally flexible, it's good practice to send only the most relevant properties for your tracking needs to keep your data clean and manageable.

## Troubleshooting Tips

**Custom properties are not being saved.** Check for any syntax errors or typos in the `properties` object within your `identify` call. Ensure that all string values are properly enclosed in quotes.
