# HubSpot Cloud

[HubSpot](https://www.hubspot.com/) is a CRM - it lets you keep track of all your customer leads. With the Freshpaint->HubSpot destination, you can create leads in HubSpot and send events to HubSpot based on your Freshpaint data

Compared to the HubSpot Web integration, this integration runs server-side. In general we recommend using this integration when possible

## Destination Info

* Supports [Track](https://documentation.freshpaint.io/developer/freshpaint-sdk-reference#track) and [Identify](https://documentation.freshpaint.io/developer/freshpaint-sdk-reference#identify) calls
* Connection Modes

<table><thead><tr><th width="175.33333333333331"> </th><th data-type="checkbox">Client-side</th><th data-type="checkbox">Server-side</th></tr></thead><tbody><tr><td>Web</td><td>false</td><td>true</td></tr><tr><td>Mobile</td><td>false</td><td>true</td></tr><tr><td>Server</td><td>false</td><td>true</td></tr></tbody></table>

## Getting Started

To set up the HubSpot integration, follow the following steps:

1. Go to the [HubSpot Cloud configuration page](https://app.freshpaint.io/destinations/apps/hubspot-cloud) in Freshpaint and click "Configure"
2. In HubSpot, go to your **Settings > Integrations > Private Apps** and click **Create Private App** and call it **Freshpaint**. Give the app read and write permissions on the **crm.objects.contacts** scope and request permission on the **analytics.behavioral\_events.send**&#x20;

   <figure><img src="https://1666823438-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MA7aDqsXMFbUsWVqonF%2Fuploads%2FfadQ0utJuZiapfSIWUrq%2FPasted%20Graphic%2064.png?alt=media&#x26;token=3572859f-66b6-4ba3-a0fe-206d215f95fc" alt=""><figcaption></figcaption></figure>

   <figure><img src="https://1666823438-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MA7aDqsXMFbUsWVqonF%2Fuploads%2FUn8Dw4K0M8kBVCBn5akb%2FFreshpaint.png?alt=media&#x26;token=db146cb9-56fa-4d51-85e3-2a065080fd0d" alt=""><figcaption></figcaption></figure>

   <figure><img src="https://1666823438-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MA7aDqsXMFbUsWVqonF%2Fuploads%2FmLHa4TfnYYQ7s1iyb9dF%2FPasted%20Graphic%2066.png?alt=media&#x26;token=0313f122-8654-48b7-ab13-be3f201663b5" alt=""><figcaption></figcaption></figure>

   <figure><img src="https://1666823438-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MA7aDqsXMFbUsWVqonF%2Fuploads%2FKq9G5oJJGEZev2lE0PpS%2FPrivate%20apps.webp?alt=media&#x26;token=daa2c9c6-454e-4af4-b63c-dce59462c85d" alt=""><figcaption></figcaption></figure>
3. After creating the app, you will be given an API key which you should provide to Freshpaint ![](https://1666823438-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MA7aDqsXMFbUsWVqonF%2Fuploads%2FpwUCwHDe39JklMi2ENpT%2Fimage.png?alt=media\&token=4d11e686-55d0-43a7-919a-74a16e95c257)

   <figure><img src="https://1666823438-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MA7aDqsXMFbUsWVqonF%2Fuploads%2F5kKH04o4KQqS91iO0zwz%2Fimage.png?alt=media&#x26;token=c6b007a1-de43-4475-b508-07d0fdca2fad" alt=""><figcaption></figcaption></figure>
4. If you want to send events to HubSpot, you will first need to set up [Custom Behavioral Events](https://developers.hubspot.com/docs/api/analytics/events) see the section below on sending Custom Behavioral Events to HubSpot

## Identify

When you call [freshpaint.identify()](https://documentation.freshpaint.io/developer/freshpaint-sdk-reference#identify), Freshpaint will create or update a [contact](https://developers.hubspot.com/docs/api/crm/contacts) in HubSpot based on the the email of the user by calling Hubspot's contacts API at: `/crm/v3/objects/contacts` .

When creating a new contact, you should always include `email`, because email address is the [primary unique identifier ](https://knowledge.hubspot.com/crm-setup/deduplication-of-contacts-companies-deals-tickets#automatic-deduplication-in-hubspot) used by HubSpot to avoid duplication.

{% hint style="info" %}
In order for an identify call to succeed to HubSpot, you will need to provide the user's email either as the user ID in the identify call or as the `email` user property in the identify call.
{% endhint %}

{% hint style="warning" %}
HubSpot has strict limitations on the properties you can attach to contacts. See the section on Property Limitations below.
{% endhint %}

Here is an example of an identify call:

```
freshpaint.identify({
 "email": "ada.lovelace@example.com",
 "name": "Ada Lovelace"
});
```

Contacts created by Freshpaint will show up under the Contacts tab in Hubspot.&#x20;

<figure><img src="https://1666823438-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MA7aDqsXMFbUsWVqonF%2Fuploads%2FMISDdLYAedY99oAdKbik%2Fimage.png?alt=media&#x26;token=1f2ed466-b06e-43ff-ba63-8375c83a43cd" alt=""><figcaption></figcaption></figure>

## Events

When you send events to HubSpot, Freshpaint will send the events as [Custom Behavioral Events](https://developers.hubspot.com/docs/api/analytics/events) to Hubspot's [Behavioral Events API](https://developers.hubspot.com/docs/api/analytics/events) at: <https://api.hubspot.com/events/v3/send>

Before you can send an event to HubSpot, you will need to set up a corresponding Custom Behavioral Event in HubSpot. To set up a Custom Behavioral Event:

1. Go to **Reports > Analytics Tools** and click **Custom Behavioral Events**
2. Click **Create Event** and **Code Wizard**
3. Provide the name and properties of the event you want in HubSpot
4. When asked how you want to send the event to HubSpot select **Send data to HubSpot**
5. You will be given a Tracking ID. This ID is the name of the event you need to provide to HubSpot. When you want to send an event in Freshpaint to HubSpot, you will need to set up a [rename event transformation](https://documentation.freshpaint.io/transformations) to rename the event to the given Tracking ID/Internal Name &#x20;

   <figure><img src="https://1666823438-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MA7aDqsXMFbUsWVqonF%2Fuploads%2FRSHYXo1dDeB3yWyZQo3k%2FPasted%20Graphic%2070.png?alt=media&#x26;token=1f390076-d321-41fb-b4b3-172deab16461" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
HubSpot has strict limitations on the properties you can attach to events. See the section on Property Limitations below.
{% endhint %}

{% hint style="warning" %}
The event MUST have the same name as the HubSpot tracking ID/Internal name in order for the event to populate to HubSpot.&#x20;
{% endhint %}

<figure><img src="https://1666823438-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MA7aDqsXMFbUsWVqonF%2Fuploads%2FqWBVqWfHzsrwdSDkqVpD%2FPasted%20Graphic%2069.png?alt=media&#x26;token=cdf72765-a9bb-4740-9792-a0c3b5193cbf" alt=""><figcaption></figcaption></figure>

## Configuration Options

### Connection Mode Settings

Only server-side connection mode is available for this destination. All events will be sent to HubSpot using Freshpaint's servers. Your website will not send data directly to HubSpot.&#x20;

### Event Transformations

Set up transformations to modify your data before it's sent to your destination. Read more about transformations [here](https://documentation.freshpaint.io/data-management/transformations).

<figure><img src="https://1666823438-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MA7aDqsXMFbUsWVqonF%2Fuploads%2FK6WG04hQZD1IMAfQFSjA%2Fimage.png?alt=media&#x26;token=ca652fec-4467-4521-9c88-cc347cf20479" alt=""><figcaption></figcaption></figure>

## Property Limitations

HubSpot has strict limitations on properties. HubSpot only accepts a property if the name of the property is less than 50 characters and only consists of lowercase letters, numbers, and underscores.&#x20;

Additionally, HubSpot only supports properties with either a string or numeric value. If you have a property name that does not fit this criteria, look at using a [property transformation](https://documentation.freshpaint.io/transformations) to convert the property into a format HubSpot supports.

#### Why aren’t my custom behavioral events appearing in HubSpot? <a href="#why-arent-my-custom-behavioral-events-appearing-in-hubspot" id="why-arent-my-custom-behavioral-events-appearing-in-hubspot"></a>

HubSpot limits the number of event properties per event. Each event can contain data for up to 50 properties. If this limit is exceeded, the request will fail. See [HubSpot documentation](https://knowledge.hubspot.com/analytics-tools/create-custom-behavioral-events#define-the-api-call) for other limits.

To view an event's available properties:

* In HubSpot, navigate to **Reports** > **Analytics Tools**.
* Click **Custom Behavioral Events**.
* Click the **name** of the event.
* Click the **Properties** tab.
* In the properties table, view the property type under the name of the property.&#x20;
