APIs & Integrations

michaelgiaimo
Participant

Custom Events for Metadata?

SOLVE

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?

1 Accepted solution
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Custom Events for Metadata?

SOLVE

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.

Isaac Takushi

Associate Certification Manager

View solution in original post

0 Upvotes
4 Replies 4
IsaacTakushi
HubSpot Employee
HubSpot Employee

Custom Events for Metadata?

SOLVE

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.

Isaac Takushi

Associate Certification Manager
0 Upvotes
CP-BWG
Contributor

Custom Events for Metadata?

SOLVE
In this new documentation for the current iteration of custom events (non-legacy), it seems to suggest that custom events must be predefined in the UI and would require an id to be sent in the JS API for them to be tracked - thus removing the very handy feature you talked about above in creating dynamic events. Thoughts?

https://developers.hubspot.com/docs/api/analytics/events

Second question - do you know if event metadata is available for reference inside email templates?
0 Upvotes
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Custom Events for Metadata?

SOLVE

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.

Isaac Takushi

Associate Certification Manager
0 Upvotes
michaelgiaimo
Participant

Custom Events for Metadata?

SOLVE

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.

0 Upvotes