# User.com

[User.com](https://user.com/en/) is a popular marketing automation platform. It provides robust tools for the marketing, sales, management, and support teams to boost their brand value, enhance customer engagement, and increase conversions.

Find the open source code for this destination in this [GitHub repository](https://github.com/rudderlabs/rudder-transformer/tree/main/src/v0/destinations/user).

## Connection compatibility

{{< destination-config >}}

## Get started

Once you have confirmed that the source platform supports sending events to User.com, follow these steps:

1. From your [RudderStack dashboard](https://app.rudderstack.com/), add a source. Then, from the list of destinations, select **User.com**.
2. Assign a name to the destination and click **Continue**.

## Connection settings

To successfully set up User.com as a destination, you will need to configure the following settings:

- **Public REST API Key**: Enter your public User.com REST API key. 
- **App Subdomain**: Enter the subdomain of your User.com app.

{{< info >}}
For more information on obtaining the public REST API key and app subdomain, see the [FAQ]({{< ref "#faq" >}}) section below.
{{< /info >}}

- **Map Rudder user attributes to User.com attributes**: With this setting, you can map the RudderStack user attributes to specific User.com user attributes.
- **Map RudderStack event name to User.com event name**: Use this setting to map the RudderStack event names to specific User.com events. You can map one or more RudderStack events to a single User.com event but **not** vice-versa.
- **Map your event property**: Enter the RudderStack and User.com event properties you want to map for the above-mentioned event names. You can map a RudderStack property only to one User.com property and vice-versa.
- **Map Rudder company attributes to User.com company attributes**: Use this setting to map the RudderStack company attributes to specific User.com company attributes.

## User lookup

{{< info >}}
This functionality is applicable only for the `identify`, `track`, and `page` calls.
{{< /info >}}

RudderStack looks up a user in User.com using the `userKey`, `email`, or `phone` properties.

- You can pass the `userKey` in the `externalId` array:

```javascript
"externalId": [{
  "type": "userKey",
  "id": "uehfuuiuednjk"
}],
```
- You can pass the `email` or `phone` in the `integrations` object:

```javascript
integrations: {
user: {
  lookup: "email/phone"
}
});
```
{{< warning >}}
You must pass only one of `email` or `phone` in `lookup`. Also, `email` or `phone` (whichever is passed) must have unique values in User.com.
{{< /warning >}}

The precedence order for looking up a user based on the above properties is:

- The `userKey` is given the highest priority.
- The `lookup` value is given the second highest priority. If `phone`/`email` (whichever is passed) is not found, RudderStack will throw an error.
- If none of the above is present, RudderStack falls back to the `userId`. If not found, RudderStack will throw an error.

## Identify 

You can use the [`identify`]({{< ref "event-spec/standard-events/identify.md" >}}) call to create a new user in User.com. If the user already exists, RudderStack updates the user details.

A sample `identify` call is shown below:

```javascript
rudderanalytics.identify('1hKOmRA4el9Zt1WSfVJIVo4GRlm', {
      firstName: 'Alex',
      lastName: 'Keener',
      email: "alex@example.com"
    }, {
      externalId: [{
        type: "userKey",
        id: "Df344sdFgdDsS4"
      }],
      integrations: {
        User.com: {
          lookup: "email"
        }
      }
    );
```

#### Traits mapping

The following table lists the mappings between RudderStack and User.com properties for `identify` call:

| RudderStack property | User.com property | 
| :-------| :--------| 
| `userId` <br /> `traits.userId` <br /> `traits.id` <br /> `context.traits.userId` <br /> `context.traits.id` <br /> `anonymousId` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `custom_id` | 
| `traits.firstName` <br /> `traits.firstname` <br /> `traits.first_name` <br /> `context.traits.firstName` <br /> `context.traits.firstname` <br /> `context.traits.first_name` | `first_name` | 
| `traits.lastName` <br /> `traits.lastname` <br /> `traits.last_name` <br /> `context.traits.lastName` <br /> `context.traits.lastname` <br /> `context.traits.last_name` | `last_name` | 
| `traits.email` <br /> `context.traits.email` <br /> `properties.email` <br /> `context.externalId.0.id` | `email` | 
| `traits.phone` <br /> `context.traits.phone` <br /> `properties.phone` | `phone_number` | 
| `traits.tags` <br /> `context.traits.tags`|`tags` | 
| `traits.address.city` <br /> `context.traits.address.city` | `city` | 
| `traits.region` <br /> `context.traits.region` | `region` | 
| `traits.country` <br /> `context.traits.country` | `country` | 
| `traits.gender` <br /> `context.traits.gender` | `gender` |  
| `traits.status` <br /> `context.traits.status` | `status` | 
| `traits.googleUrl` <br /> `context.traits.googleUrl` | `google_url` |  
| `traits.linkedinUrl` <br /> `context.traits.linkedinUrl` | `linkedin_url` | 
| `traits.twitterUrl` <br /> `context.traits.twitterUrl` | `twitter_url` | 
| `traits.facebookUrl` <br /> `context.traits.facebookUrl` | `facebook_url` | 
| `traits.avatar` <br /> `context.traits.avatar` <br /> `traits.avatarURL` <br /> `context.traits.avatarURL` <br /> `traits.avatar_URL` <br /> `context.traits.avatar_URL` | `gravatar_url` | 
| `traits.timezone` <br /> `context.traits.timezone` | `timezone` |  

## Track

You can use the [`track`]({{< ref "event-spec/standard-events/track.md" >}}) call to record a new event which, in turn, can be used to filter and bucket users in User.com.

A sample `track` call is shown below:

```javascript
rudderanalytics.track('Add to cart', {
  purchased_item: "T-Shirt",
  brand: "Zara",
  email: "alex@example.com"
}, {
  integrations: {
    User.com: {
      lookup: "email"
    }
  }
););
```

#### Property mapping

The following table lists the mappings between RudderStack and User.com properties for the `track` call:

| RudderStack property | User.com property | 
| :-------| :--------| 
| `userId` <br /> `traits.userId` <br /> `traits.id` <br /> `context.traits.userId` <br /> `context.traits.id` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `user_id`  | 
| `event` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `name` |  
| `properties` | `data` | 
| `originalTimestamp` <br /> `timestamp` | `timestamp` | 

## Page

The [`page`]({{< ref "event-spec/standard-events/page.md" >}}) call lets you record your website's page views with any additional relevant information about the viewed page.

A sample `page` call is shown below:

```javascript
rudderanalytics.page("section-name", {
      path: "path",
      url: "url",
      title: "title",
      search: "search",
      referrer: "referrer",
      phone: "1-202-555-0146",
    }, {
      integrations: {
        User.com: {
          lookup: "phone"
        }
      });
```

#### Property mapping

The following table lists the mappings between RudderStack and User.com properties for `page` call:

| RudderStack property | User.com property |  
| :-------| :--------| 
| `userId` <br /> `traits.userId` <br /> `traits.id` <br /> `context.traits.userId` <br /> `context.traits.id` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `client_user`  | 
| `traits.url` <br /> `context.traits.url` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `page_domain` | 
| `traits.path` <br /> `context.traits.path` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `page_path` | 
| `originalTimestamp` <br /> `timestamp` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `timestamp` | 

## Group

You can use the [`group`]({{< ref "event-spec/standard-events/group.md" >}}) call to create or update a company profile and associate a user with it.

A sample `group` call is shown below:

```javascript
rudderanalytics.group(
  "group01", {
    name: "Alex Keener",
    phone: "1-202-555-0146",
    size: 51,
    zipcode: 90009,
    street: "6649 N Blue Gum Street",
    city: "New Orleans",
    region: "Louisiana",
    country: "USA"
  },
);
```

#### Property mapping

The following table lists the mappings between RudderStack and User.com properties for the `group` call:

| RudderStack property | User.com property |  
| :-------| :--------| 
| `userId` <br /> `traits.userId` <br /> `traits.id` <br /> `context.traits.userId` <br /> `context.traits.id` <br /> `anonymousId` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | `custom_id`(user) | 
| `groupId` <br /> `traits.groupId` | `custom_id`(company) |  
| `traits.name` | `name`(company name) | 
| `traits.email` <br /> `context.traits.email` <br /> `properties.email` <br /> `context.externalId.0.id` | `email` | 
| `traits.address` <br /> `context.traits.address` | `address` | 
| `traits.address.city` <br /> `context.traits.address.city` | `city` |
| `traits.region` <br /> `context.traits.region` | `region` | 
| `traits.country` <br /> `context.traits.country` | `country` | 
| `traits.description` | `description` | 
| `traits.phone` <br /> `context.traits.phone` <br /> `properties.phone` | `phone_numbers` | 
| `traits.zip` <br /> `traits.zipcode` <br /> `traits.address.zipcode` <br /> `traits.address.postalcode` <br /> `context.traits.zip` <br /> `context.traits.zipcode` <br /> `context.traits.address.zipcode` <br /> `context.traits.address.postalcode`| `postal_code` | 
| `traits.size` | `size` | 
| `traits.tags` | `tags` | 

## FAQ 

#### Where can I find the User.com public REST API key?

To get your public REST API key, follow these steps:

1. Log into your [User.com dashboard](https://app.user.com/accounts/login/) and go to your app. 
2. Click **Settings** > **App settings** > **Advanced** > **Public REST API keys**.
3. Click **Create API key**:

{{< image src="images/event-stream-destinations/user-com-dashboard.webp" alt="User.com connection settings" >}}

#### Where can I find the User.com app subdomain?

To get your app subdomain, follow these steps:

1. Log into your [User.com dashboard](https://app.user.com/accounts/login/) and go to your app. 
2. Click **Settings** > **Setup & Integrations** to see the app domain. The subdomain is the part of the complete domain excluding `.user.com`:

{{< image src="images/event-stream-destinations/user-com-dashboard-2.webp" alt="User.com connection settings" >}}

