Integrate Segment with Hubspot
Data

Integrate Segment with Hubspot

We wanted Hubspot to show when users sign up for our application and when they last log in. You would think this would be easy....

Our CRM of choice is Hubspot. Currently it's populated from a number of lead generation sources, the two main ones are our typeform that is embedded in a Journey and our Product Hunt upcoming page.

We've integrated both of these sources with Hubspot via Zapier.

We also wanted to capture when people sign up for our application. Not a terribly controversial request for a bottoms up B2B product! Unfortunately, Hubspot does not have a Segment.com integration and there is no easy way to create contacts within Hubspot on signup to an application without a bunch of fairly crufty code.

We decided to use Zapier — it wasn't as easy as we expected but we made it work.

Connect Segment to Zapier

First, we created a Zapier Catch Hook and entered that URL in our Segment destination.

This meant that ALL Segment events were being sent to Zapier. How Zapier is okay with this is a wonder to me as we pay Zapier $99/month and we now blast them with thousands of events per day! (Since Segment tracks page views for our site and marketing site and such)

Filtering the Zap

The first thing to do is now ... make Zapier throw away 99.9999% of all events it sees. We were really only interested in two Segment events: Signups and Logins.

We started by using a Zapier Filter that filtered for the property name "Sign Up" but the problem with that is if you wish to update different property fields for Sign Ups vs. Logins, you cannot easily do this. Your solution is to either use two Zapier webhooks (truly insane) or do a fancier filter.

Zapier Paths

Zapier Paths are the replacement for the Zapier "Catch" Step that is now deprecated. Zapier Paths allow you to create case statements within Zaps. So cool. We did this:

And an example of the filter was this — filtering for Segment.com Logins:

and filtering for Segment.com Sign Ups:

I include the screenshots because it is exhaustingly challenging to see the correct data in Zapier. Since you're sending thousands of events to Zapier, and Zapier will only allow you to preview 3 events and then will randomly preview a different 3 events — it takes forever to see an event you actually want to use! This is actually the third time I have created this zap in the past 5 years so I am writing this post as much for me as anyone else...

Writing from Zapier to Hubspot

Once you have the relevant Zapier filters setup, writing the data to Hubspot is fairly straight forward.

First, you want an "Update or Create a Contact" action within Hubspot after each rule, and then simply insert the email and the timestamp of the event:

Another big gotcha is that identify calls have a traits email property and events have an email property — this broke my brain, especially since its so hard to preview the events. You need to make sure you select the correct email property for each Signup and Login filter:

The email property for when a user logs in (note that it says No Data because it is currently using a Sign Up Segment in their test console....)
The email property for when a user signs up

What you'll have to do is run a bunch of Segment events until you have a "Sign Up" event in the test console, then create the "Sign Up" Zap filter, and then run a bunch of Segment events until you have a "Log In" event in the test console, and then setup the "Log In" Zap filter. If you use the same email property in both Zaps it will not work, since the email field will not be found when filtered. You'll just get an "email property does not exist" error and the Zap will wait and keep retrying and failing.

You'll also obviously need to create a property within Segment at the contact level that stores the Signup Date, since the creation data may not work if updating an existing contact. Fortunately Hubspot is smart enough to take the above timestamp and truncate it to simply be YYYY-MM-DD and seemingly it just loses the actual timestamp. No big deal.

And you're done! Contacts will not be updated in Hubspot with their signup and login date.

Next week we'll discuss how to create deals for every contact within Hubspot automatically.....

Author

Peter Clark

i have spent the last 15 years making growth tools and running growth teams. i like dogs, pastries, golf and design.

meet with brendan

Related posts

No items found.