PLG Motions Framework: The 3 Product-Led Motions
Download now!

How to Connect Segment to Hubspot Marketing Automation

Usha Vadapalli
October 4, 2023

When you connect Segment, a powerful data management platform, with HubSpot marketing automation you're essentially creating a bridge between your product data and your marketing strategy. Segment helps you gather data from various sources, like your website, web and mobile apps, etc. and its  integration with HubSpot is meant to help you send the right message to the right people at the right time using that data.

With the data from Segment, HubSpot should be able to create highly personalized marketing campaigns, track customer behavior, and automate tasks, making your marketing efforts more efficient and effective.

In this blog post, we’ll detail the steps to connect Segment to HubSpot.

Prerequisites to integrating Segment and HubSpot

Before starting the integration, ensure you choose the connection mode that aligns with your data source and needs.

  • HubSpot integration with Segment primarily works in "device mode," which is suitable for client-side data collection using the open-source Analytics.js library.
  • Page tracking, or "page calls," is supported in this device mode for web interactions.
  • HubSpot also offers a "cloud mode" for server-side and mobile sources, which is separate from device mode.

Refer to the documentation for details on these modes.

How to Connect Segment CDP to Hubspot:

  • Log into your Segment account and navigate to Catalog.
  • In the Catalog, search for "HubSpot." Select it, and then choose which of your sources you want to connect this destination to.
  • Since HubSpot no longer supports generating new API Keys, using a Private App Token is the way to go. To create a private app access token in your HubSpot account, go to Integrations > Private Apps. For more information on how to create one, check out HubSpot’s documentation.

Note: To access private apps on your HubSpot account, you need super admin access.

  • Take the generated token and enter it into the Private App Token field within the Segment web application. For this integration to work properly, make sure to grant the following permissions:
business-intelligence, crm.objects.contacts.read, crm.objects.contacts.write, crm.schemas.contacts.read, crm.objects.companies.read, crm.objects.companies.write, crm.schemas.companies.read.
  • Now, go to the Settings page in the HubSpot to locate your unique Hub ID. Input this Hub ID into the corresponding field in the Segment web app.
  • After configuring these settings, activate the destination from Segment. It might take approximately 45 minutes for your changes to show up through the Segment CDN (Content Delivery Network). Following this, Analytics.js will commence asynchronously loading the HubSpot snippet and begin recording data.

To send data to HubSpot, you need to initiate a few calls

Page

Analytics.js needs an initial Page call to transmit data to HubSpot. The Segment snippet automatically includes this initial call by default.

If you're new to Segment Specs, check them out to get a grasp of how the Page method functions. For instance, here's what a sample call looks like: analytics.page().

Note that HubSpot provides support for Page calls specifically through device-mode connections originating from Analytics.js sources.

Identify

Two conditions must be met to successfully create or update a contact via HubSpot's device-mode integration. Firstly, the "Identify" calls should include a value for "traits.email," and secondly, these "Identify" calls should be accompanied by either a "Page" or a "Track" call.

Here's an example of an "Identify" call:

analytics.identify('user1234', {
email: 'petergibbon@email.com',
firstname: 'Peter',
lastname: 'Gibbon'
})

When it comes to HubSpot's device-mode integration, there are two conditions for an Identify call to create or update a contact:

  • Identify calls must include a value for traits.email.
  • An Identify call must be followed by a Page or Track call. For more details, refer to HubSpot's documentation.

In case you're using HubSpot's cloud-mode integration, an Identify call can update records without requiring a Page or Track call.

Note that HubSpot doesn't accept trait keys containing uppercase letters or spaces. Segment automatically converts any custom traits to lowercase and replaces spaces with underscores.

HubSpot also filters out traits that aren't contact fields in HubSpot.

To see the available fields, navigate to Settings > Data Management > Objects > Contacts, and select Manage contact properties under the Setup tab. Examples of field names include firstname, lastname, company, and phone.

Additionally, if you specify a company name using traits.company.name, it appears as a property of the contact in HubSpot's UI under About [contact] > View > View All Properties, but it doesn't appear as the user's company under [contact]'s Company.

Finally, HubSpot identifies certain fields as special fields, including address, city, companyName, email, firstName, lastName, position, phone, and zip.

Track

For Segment to pass traits from an Identify call to your Track call and send them as custom events to HubSpot, you need a HubSpot Enterprise account.

Here’s an example call:

analytics.track("Clicked Buy Now button", {
value: 20.5
})

Note that, while the event will be visible in your HubSpot UI, it may take up to 60 minutes to appear in the graph visualization.

Server

If you're using one of Segment's server-side sources, you can link an event to the right contact in HubSpot by providing their email as "properties.email." Here's an example in

Python:

analytics.track(
user_id='YOUR_USER_ID',
event='Bought Item',
properties={
'email': 'peter@example.com',
}
)

Your HubSpot eventId in this case is 'Bought Item.' If you want to use an existing eventId, simply use it instead of 'Bought Item.' If you're creating a new event, you can use any event label, and HubSpot will automatically create it for you.

Segment recommends sending traits with an Identify call, but you can also set HubSpot properties in a track call from any server-side source, following HubSpot's events API rules. This is especially useful if you're running low on HubSpot API calls with Identify requests.

Include HubSpot contact properties like this:

analytics.track(
user_id='YOUR_USER_ID',
event='Bought Item',
properties={
'email': 'peter@example.com',
},
context={
'traits': {
'firstname': 'Peter',
'lastname': 'Gibbons'
}
}
)

This way, you can efficiently manage your data in HubSpot and ensure it's associated with the right contacts. But, there are many limitations in the way this integration works that don’t help users achieve their goals.

Before Connecting Segment and HubSpot

API rate limitations:

The main reason a PLG business using Segment as their data pipeline wants to integrate it to HubSpot is to be able to send data like product events to trigger customer communications via HubSpot. The biggest hindrance to this goal is HubSpot’s API rate limitation.

These limits determine the maximum number of requests that Segment can make to HubSpot's API, and they vary based on your HubSpot plan. And, naturally, product events are on the higher side in volume.

Exceeding HubSpot’s API rate limitations allotted to the user’s pricing tier can lead to throttling and disruptions in data transfer, potentially affecting the integration's performance; not to mention the exorbitant costs of upgrading the limit.

Custom event naming requirement:

HubSpot requires that you create custom event names to be used within their platform. This means that the event names you've been using in Segment may not directly translate to HubSpot. As a result, you may need to recreate or duplicate these event definitions specifically for HubSpot. For example, an event like "Product Purchase" in Segment might need to be recreated as "Buy Product" in HubSpot.

That means, you now have to manage two sets of event names: one in Segment and another in HubSpot, adding complexity to data management. This redundancy can lead to confusion and requires additional effort and resources to ensure consistency between the two platforms.

The custom event naming constraint from HubSpot goes against the convenience of using Segment for event tracking and sharing.

Inability to achieve PLG goals:

The purpose of integrating a CDP like Segment with a marketing automation tool like HubSpot is mainly to guide marketing activities equipped with intelligence on end-user activities. HubSpot lacks certain API functionalities, such as tracking web events or preserving pre-conversion analytics data, which are crucial for the intended use case.

As a result, you have to resort to writing custom code or depending on engineering to help set up and manage the integration.

The compatibility of these two platforms falls short in most common use cases a typical PLG SaaS company might want to achieve with this integration.

Inflection and Segment

If you are a PLG business using Segment to streamline the use of end-user data to personalize your customer communication at scale, Inflection.io is a better alternative.

Inflection is the B2B marketing and customer communication platform built for the modern data stack. Inflection’s native integration with Segment as both source and destination, enabling you to execute large-scale personalized marketing campaigns. Combine product activity data from Segment and CRM data from Salesforce to build a unified view of product activity data, person, and account information to build and run product-led growth campaigns.

Many Segment users have embraced Inflection to drive the success of their product-focused marketing campaigns. With bi-directional integration, you can also add campaign data from Inflection to compare and measure success metrics in your favorite BI tools like Amplitude or Mixpanel via Segment. This lets you map and understand your customer journey at a higher level.

Request a demo to see how Inflection works.

Get monthly blog roundup

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.