Custom Events for Metadata?

contacts

#1

We have a lot of metadata in the dataLayer object already for things like Google Analytics and Tag Manager. I want to take advantage of this information in HubSpot. For example, we have in the dataLayer:

"subjectArea1": "Golfing",

The end goal is to be able to create lists and segment contacts on this - for example, users who have read more than 10 Golfing stories.

I'm a little unsure on how to best set this up. Should I just send a separate event for each Subject Area? (Golfing, Travel, Sports, etc) and then would all of these potential Event values need to be first set up in HubSpot?

Or is there a better way?


#3

Welcome, @mgiaimo!

From your use case description, I would say the Events JavaScript API is indeed your best bet.

If you're looking to track and segment on a visitor's engagement with certain topics, I would recommend sending a separate event for each subject area. While you can create new events by passing a string, if you have a set list of topics, it would be better to just create them in HubSpot first and implement the different events on each subject-related page.

Alternatively, if you could use the tracking code's identify method to update contact properties, but you wouldn't be able to, for example, add 1 to the existing property value. Thus, it wouldn't be as effective in counting engagements.


#4

Thanks for the reply, Isaac!

By this do you mean we can just push events via API and they'll be created if they don't already exist in HubSpot? Because we probably have over 100 in total, and if we don't have to manually create each one through the HubSpot UI that'd be ideal.


#5

Yep, exactly, @mgiaimo!

Per the _ Event IDs and names_ section of this article:

You can trigger an event using a string name for the event. If you use a name, and there is not an existing event that already has that name, a new event with that name will be dynamically created. If there is an event was previously dynamically created with a matching name, then the event will count towards that existing event. This allows you to dynamically create new events, without needing to create them manually in HubSpot.

Keep in mind that events created dynamically by name can only be created once . If you delete an event that was created this way, a new event will not be created if you try to dynamically trigger an event with the same name.