POST
/
trackEvent
curl --request POST \
--url https://js.hs-scripts.com/trackEvent \
--header 'Content-Type: application/javascript' \
--data '"_hsq.push(['\''trackEvent'\'', { id: '\''000000001625'\'', value: 100 }]);"'
Track behavioral events in your HubSpot reports. Events can be tied to a contact record so that you can see if/when a contact triggered that event.
Note: Events will only be processed for accounts with Marketing Hub Enterprise.

Usage

Track by Event ID

var _hsq = window._hsq = window._hsq || [];
_hsq.push(['trackEvent', {
  id: '000000001625',
  value: 100
}]);

Track by Event Name

var _hsq = window._hsq = window._hsq || [];
_hsq.push(['trackEvent', {
  id: 'custom_event_name',
  property1: 'value1',
  property2: 'value2'
}]);

Event IDs vs Names

  • Event ID: Use numerical IDs for events created in HubSpot (Reports > Analytics Tools > Behavioral Events)
  • Event Name: Use string names to dynamically create new events. If an event with that name doesn’t exist, it will be created automatically
  • Events created in the HubSpot app cannot be triggered by name, only by ID
  • 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

Body

application/javascript

Event tracking data

The body is of type object.

Response

200

Event tracked successfully