APIs & Integrations

Not applicable

Is it possible to add custom properties to event?

hi,
I created new event called AddToCart in my Testing Hub. the code below works but I want to track more information like item no , item name . what should I do ? I am new for HubSpot , need you guys help . Thanks in advanced .

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

added More information

step 1 : We created form named lktest_form in Hubspot portal. The form has two fields : Email and cart_id
step 2 : We created submission event lktest_event that links to lktest_form in HubSpot portal
step 3 : we added JS code below to send lktest_event in our website . Hubspot catched lktes_event but did not catch email and cart_id values

var _hsq = window._hsq = window._hsq || [];
_hsq.push(["lktest_event",{
email:"lorne@dvp.net",
cart_id: "abcdeft"

}]);

0 Upvotes
6 Replies 6
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Is it possible to add custom properties to event?

Hi @lindadvp and @LorneKates,

Enterprise events (i.e. events triggered with the trackEvent method of the Tracking Code API) don't have the ability to include custom event properties. These events are relatively simple in functionality; they basically track whether or not an event has happened, and nothing more. Even the value field isn't technically an 'event property'; the value increments in reporting and on the contact record, but otherwise isn't associated with a given event. In order to track a list of items added to a visitor's cart, you'd need to use the identify method to store that information on the contact record.

If you need more powerful and/or extensible events, you'll need to use the Timeline API (see below). The Timeline API allows you to create event templates that include custom properties and iframe actions, among other things. With the Timeline API, you could create event templates that include enumerations of cart items and cart state info, among other things. I'd encourage you to check it out, since I believe it'd be a better fit for the use case you're describing here:

0 Upvotes
terrance
Participant

Is it possible to add custom properties to event?

@Derek_Gervais The reason this comes up from time to time is this is because there are two types of tracking in most modern platforms; Stateful and Event Data. In the world of warehousing you typically have an event, which is a table, and then columns, which are properties. It sounds like Hubspot has just an events table with columns related to the generic event.

I highly suggest you review the Object Action framework posted by Segment: https://segment.com/academy/collecting-data/naming-conventions-for-clean-data/ . It will clearly explain why simplicity in naming is best and why fewer events with more defining properties is the way to go. It allows for way more flexibility in looking at your data. Hubspot on the other hand is fine with up to 2000 custom events per account.

Most other tracking systems have moved to this level of flexibility which is why it comes up from time to time on this forum.

Example:

Event: "Added To Cart"
Properties: user_id, first_name, last_name, url, button_used, timestamp, product_category

Now, you can look at all items added to the cart segmented by time of day and what buttons were used to see if some buttons are used more at different times of the day. You can also group cart additions by product category to see that shoes are most commonly added on a Sunday and tshirts on a Monday. Stuff like that. Hubspot is making leaps and bounds as far as analytics go inside the portal, but I have a feeling you all will move to this model at some point.

0 Upvotes
Not applicable

Is it possible to add custom properties to event?

@Derek_Gervais

Thank you very much. your information is very useful to me.

Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Is it possible to add custom properties to event?

Hi @lindadvp,

That code is perfect for triggering the AddToCart event, but an event like that can't be used to update a contact record by itself. In order to update contact properties, you'll need to take advantage of the identify method of the tracking code API (see below). The identify method allows you to pass an email and a number of other contact properties into the tracking code, which when passed to HubSpot via another event will update and/or create contact record.

You'll want to take the contact's email address (and the other contact properties you want to update) and pass them into an identify call before triggering the AddToCart event. The order should look like this:

  1. Form submission
  2. identify call with relevant data
  3. Trigger AddToCart event
0 Upvotes
Not applicable

Is it possible to add custom properties to event?

Hi @derek_gervais, thank you for your response.
My issue is not identifying a visitor , is not updating a contact. My issue is to Trigger AddToCart event with more custom properties.
My scenario: There is an AddItemToCart button on product detail page, when shoppers click the button, website will trigger AddtoCart event created in HubSpot and push cart_id with AddtoCart event to Hubspot.

My testing code is as following:

var _hsq = window._hsq = window._hsq || [];_hsq.push(["identify",{ email: 'tester@dvp.net', id: '', cartid : 'y5o3tzsft1nqya54obkwiqin'}])

var _hsq = window._hsq = window._hsq || [];_hsq.push(["trackEvent",{ id:"000005995115", value:"25.90",cart_id:"a"}]);

The code above is ok for triggering the AddtoCart , but I can’t see cart_id information coming in HubSpot portal .

There are 4 Events: Clicked Element, Submitted form, Visited URL, Custom Event in Hubspot . I tried Submitted form event and custom event. Both events does not work for my scenario.

Question : which event can be used to solve the issue? How to use the event ? Could you please give me details step by step and some code example? Your help is greatly appreciated.

Thank you again.

@Derek_Gervais
after inspecting network , I found cart_id=a in post URL . I believe cart_id has been sent to Hubpost . Why didn't Hubspot catch it ?

"https://track.hubspot.com/__ptq.gif?id=000005995115&value=25.90&cart_id=a&k=3&n=000005995115&m=25.90..."

0 Upvotes
Not applicable

Is it possible to add custom properties to event?

Hi, I'm also a dev working on this project. Just to confirm in case it gets asked-- yes, we created a form with a field for cart_id.

If I log into the portal, I can see the even arriving on the dashboard for the contact. I can see that it was the correct event. But if I check the form associated with that event, it says 0 completions.

The reason we're talking both contacts and events is because what needs to be done:

  1. Each page, include the tracking code
  2. Each page, also fire an Identify event so the individual can be identified
  3. After some actions (AddToCart, Checkout, OrderComplete), associate those actions 1-to-many with contacts

Ideally, we'd be able to log into the Hubspot dashboard and see Shopper XYZ browsed around this site to this page, this page, this page, this page.

Then Shopper XYZ added Item A to cart. Then browsed. Then added Item B to cart. The clicked Checkout. Etc.

It's important to be able to track WHICH item was added to cart. In addition, some of the custom properties being set include more information about the state of the cart, so that later on our client can do dropped cart tracking / emails.

0 Upvotes