Solved

A user property is not removed/updated on an event when a null or undefined value is passed in, why is this?

  • 17 February 2023
  • 2 replies
  • 227 views

Hi, I wanted to clarify some behavior I’m seeing in our Amplitude events.

I’m looking at a user’s event stream and see that for their events they have a user property, let’s just say it’s called name and it has a value of “Chris”. 
 

Then I use the Amplitude SDK to log another event, something like this

amplitudeClient.logEvent('Changed name', {user_properties: { 'name': undefined }});

 

I notice that in this event, the user property will still show up as “Chris” instead of being nullified or removed. I was wondering why this is the case and how to remove user properties if they are undefined/null. Would I need to use the Identify API to explicitly remove the property? 

icon

Best answer by Saish Redkar 17 February 2023, 21:24

View original

2 replies

Userlevel 7
Badge +10

Hi @chrish 

Most likely user_properties: { 'name': undefined } will act as if you didn’t update the property and will keep the previous name value. Try stringifying the value as { 'name': ‘undefined’ }. You can also use { 'name': ‘none’ }

AFAIK, there isn’t a way of removing an already ingested user property from the events. Even if you don’t send that property on events moving forward, the last updated value will persists on all those future events.

Here’s an article of how Amplitude applies user props - https://help.amplitude.com/hc/en-us/articles/115002380567-User-Properties-Event-Properties#applying-user-properties-to-events

Hope this is useful.

I see, thanks for the quick reply Saish! 

Reply