How to send array as properties on custom events

Hello,

I am new to custom events and we would like to send from our webshop an array of products (basic info like product name, product id and quantity) for abandoned carts.

Is this possible to send this to a custom event? It seems I can only define properties such as string, timestamp, enumeration, etc.

Thanks!

Hi @AndPat,

When selecting the API option for setting up custom events, there is a graphic that hints about sending JSON data as a string.

You could send that as string to be stored as a property value in HubSpot. Then you could use a workflow with a custom coded action to process that property value to fit your use case.

Thanks! We are using JavaScript events. Would something like this be possible there also?

It should be. Here is a simple example snippet of a custom event that would store a cart with 2 t-shirts and 1 pair of shoes.

Assuming the property in HubSpot would be called “product_array” and the JSON would be something like this:

{“cart”:[{“name”:“T-Shirt”,“qty”:2},{“name”:“Shoes”,“qty”:1}]}

_hsq.push([
 'trackCustomBehavioralEvent',
 {
 name: "CUSTOM_EVENT_ID",
 properties: {
 product_array: "{\"cart\":[{\"name\":\"T-Shirt\",\"qty\":2},{\"name\":\"Shoes\",\"qty\":1}]}",
 },
 }
]);