Solved

Why is Mixpanel not showing event properties with the value false in PHP/Laravel?

  • 13 October 2020
  • 1 reply
  • 85 views

When sending an event with a property that can either be true or false, the property is shown when there is true value on the property and is not shown when it’s false.

I’m using a Laravel library for Mixpanel - https://github.com/GeneaLabs/laravel-mixpanel

For instance, I have an event called ‘Test event’ and a db property test_property that has a boolean value (true or false).

$this->mixPanelClient->track(    "Test event",    [        'Test property' => is_null($test_property) ?: false,    ]);

 

Unit testing is working in a case when test_property is false, but when I go to Mixpanel live view and check the event the property is not there. It only shows it when it is true.

Does anyone else is experiencing this issue with this library or with Mixpanel and PHP/Laravel in general?

icon

Best answer by donna 24 October 2020, 02:57

Hi there :blush:

Unfortunately, the library provided is a 3rd party library Mixpanel did not create. With that in mind, we are limited in the support we can provide for that library.

 

I’m not too familiar with PHP, but from PHP’s manual on casting: https://www.php.net/manual/en/language.types.string.php#language.types.string.casting 

Boolean FALSE is converted to "" (the empty string).

 

I’m wondering if somewhere the $test_property boolean value is being converted to a string (string)FALSE  so the event property is showing up blank on FALSE because it’s an empty string.

In which case, you could try sending the boolean values as strings like  “false” as an alternative.

 

It might be also be worth reaching out to creator of the library on Github to get more assistance on this.

View original

1 reply

Hi there :blush:

Unfortunately, the library provided is a 3rd party library Mixpanel did not create. With that in mind, we are limited in the support we can provide for that library.

 

I’m not too familiar with PHP, but from PHP’s manual on casting: https://www.php.net/manual/en/language.types.string.php#language.types.string.casting 

Boolean FALSE is converted to "" (the empty string).

 

I’m wondering if somewhere the $test_property boolean value is being converted to a string (string)FALSE  so the event property is showing up blank on FALSE because it’s an empty string.

In which case, you could try sending the boolean values as strings like  “false” as an alternative.

 

It might be also be worth reaching out to creator of the library on Github to get more assistance on this.

Reply


Mixpanel