There's a new version of the HubSpot API

As of November 30, 2022, HubSpot API keys are no longer a supported authentication method for accessing HubSpot APIs. Instead, you should use a private app access token or OAuth to authenticate API calls. Learn more about this change and how to migrate an API key integration to use a private app instead.

Events JavaScript API

Last updated March 18, 2021

_hsq.push(["trackEvent", { {event details} }]);

There is a new version of this API documentation, which is significantly more detailed.

Please note: Events will only be processed for accounts with Marketing Hub Enterprise.

Use this endpoint to track a custom behavioral event using JavaScript and HubSpot's tracking code. You can use events to track specific activities completed by visitors on your site. Tracked events can show up in contacts' timelines.

Use case for this endpoint: Events can capture actions like logging in. You can use data from this endpoint to segment users how have not logged in in more than seven days and target them with a re-engagement campaign.

Arguments How to use Description
Event ID id: The ID of the event. If you created the event in HubSpot, use the generated ID of the event as a string. Otherwise, you can use a string name for the event to dynamically create an event. See the overview for more details on names and ids.
Value value: The value of the event. This is an optional argument that can be used to track the revenue of an event. This value will be used to increment the hs_analytics_revenue property if the event is associated with a contact record.