Please note: trackEvent has been deprecated and no longer works. Use trackCustomBehavioralEvent instead, as documented below.
Track custom events in your HubSpot account. Custom events can be tied to a contact record so you can see if and when a contact triggered that event.
Parameters
| Parameter | Type | Description |
|---|
name | String | The internal name of the custom event, formatted as pe{HubID}_{name}. You can find the internal name either via the Custom events API or in HubSpot. |
properties | Object | An object of property names and values to send with the event. |
Usage
var _hsq = (window._hsq = window._hsq || []);
_hsq.push([
"trackCustomBehavioralEvent",
{
name: "pe12345678_my_event",
properties: {
property_name: "property_value",
},
},
]);
Migrate from trackEvent
To migrate from the deprecated trackEvent method, update your calls as follows:
- Replace
trackEvent with trackCustomBehavioralEvent.
- Replace the
id field with name, using the pe{HubID}_{name} format for the value.
- Wrap any properties you’re sending in a
properties object.
Before:
var _hsq = (window._hsq = window._hsq || []);
_hsq.push([
"trackEvent",
{
id: "custom_event_name",
property1: "value1",
},
]);
After:
var _hsq = (window._hsq = window._hsq || []);
_hsq.push([
"trackCustomBehavioralEvent",
{
name: "pe12345678_custom_event_name",
properties: {
property1: "value1",
},
},
]);