Custom Behavior Event with boolean properties bug

Hello!

I’ve got the HubSpot Tracking code installed on my site. I’m trying to send a custom behavioral event with properties. One of the properties on my behavioral event is boolean. For that property, when my javascript writes out an event with a true or null value, it gets recorded just fine in HS.

However, if I try to send a false value, it gets recorded as null (or -- in the UI).

To reproduce the problem:
1. Create a custom behavioral event with a boolean property.
2. Send a false value for the property from the js

window._hsq.push([
 'trackCustomBehavioralEvent',
 {
 name: 'pe123456_course_registration',
 properties: {
 is_working: false
 },
 },
]);

I expected to see false come through in that event for the is_working property.

In reality, I did not see the is_working property come through on the event at all.

A current work around I’m employing is to send the strings ‘true’ and ‘false’

window._hsq.push([
 'trackCustomBehavioralEvent',
 {
 name: 'pe123456_course_registration',
 properties: {
 is_working: 'false',
 },
 },
]);

and that registers the is_working property with a false value for an event.

Hi @manalive
Thank you for reaching out to the Community!
I’d like to invite some community members who are subject matter experts to join this conversation.
@coldrickjack @zach_threadint @MBERARD - Would you be able to share any insights on this? Your expertise would be greatly appreciated.
Best,
Victor

Hi @manalive :waving_hand:

Assuming your workaround sending in true/false as strings is resulting in the expected outcome, I’d just continue to take that approach. I know that boolean checkbox properties that belong to CRM records generally are set with strings (i.e. the internal valid value options are ‘true’ and ‘false’, not their boolean counterparts). This is regardless of whether the valid value options are set as strings or booleans at the time of property creation via API. For example:

POST /crm/v3/properties/TICKET

{
 "groupName": "ticketinformation",
 "name": "test_boolean_1",
 "label": "Test Boolean 1",
 "type": "enumeration",
 "fieldType": "booleancheckbox",
 "options": [
 {
 "value": true,
 "label": "Yes"
 },
 {
 "value": false,
 "label": "No"
 }
 ]
}

Results in this response:

{
 ...

 "name": "test_boolean_1",
 "label": "Test Boolean 1",
 "type": "enumeration",
 "fieldType": "booleancheckbox",
 "description": "",
 "groupName": "ticketinformation",
 "options": [
 {
 "label": "Yes",
 "value": "true", // notice the valid value option is a string
 "displayOrder": 0,
 "hidden": false
 },
 {
 "label": "No",
 "value": "false", // notice the valid value option is a string
 "displayOrder": 1,
 "hidden": false
 }
 ],

 ...
}

I hope this proves helpful. Please let me know if you have any follow-up questions.

@Victor_Becerra @zach_threadint Thanks for looking at this with me. How can this issue be reported to the HubSpot team building the tracking code? Our app code is having to do some weird conversion just for the events sent through the trackCustomBehavioralEvent code.

As a developer, if I have a boolean value and I’ve setup my custom event to be of boolean type, I would expect the api to accept boolean values. The HTTP API for event completions will only accept boolean values for this property. The other thing the value `true` works as well. It is only `false` that is the problem.

I know this is ridiculous but I looked through the analytics code from https://js.hs-analytics.net/analytics/1756911900000/20221873.js . In the hstc.tracking.Tracker.prototype.trackCustomBehavioralEvent function the false value isn’t being sent because the safeString function believes the false value isEmpty and so will return “” instead of false.

When I was seeing this behavior I felt like I was going crazy and I just had to make verify whether it was me or not lol.