Hi! I was trying to add user properties to an event and I tried doing the following:
var userProperties = { city: "San Francisco" }; // @ts-ignore var amp = amplitude.getInstance(); amp.logEvent(eventName); amp.setUserProperties(userProperties);
However, this event tracked twice: as a “Continue button clicked” event without user properties and also as a $identify event with user properties. Is there a specific way I should be configuring the user properties to add them to the specific event, rather than tracking as a separate $identify event? Thanks in advance!
Page 1 / 1
Hi @carissa.mok ! Welcome to the Amplitude Community and I’m happy to help!
Given the example you provided, it seems like you are using one of our SDKs. If so, user properties are actually sent within an $identify call so the behavior you are seeing is expected. So long as the user properties are set before the event call, the event call will pick up the user properties listed in the $identify call. When you look up this event in Amplitude, you should see that the user properties are actually on the event itself.
Feel free to read more of the Help Center article I just linked to understand how user properties work!
Hi Belinda, thanks for the response! I have a few more questions that I’m hoping you’ll be able to help me out with:
Does it matter where I set user properties? It seems that even if I do it in the same file as one particular event, the same user properties will show up for other tracked events of different types.
I deleted a user property in the Govern tab but it’s still showing up when I click into a specific event — any way to hide this?
Thanks for your help!
Sure @carissa.mok ! Happy to do so - see below:
User properties are attributes of the user so once it shows up on a user’s profile, then it will show up for all events moving forward! As such, it theoretically doesn’t matter where you set the user properties but do keep in mind again about how user properties behave if you sent it before OR after the events. I recommend reading this article I shared last time: https://help.amplitude.com/hc/en-us/articles/115002380567#applying-user-properties-to-events
To clarify, do you mean you still see the user property appear when you see an event within a user’s profile? Or do you mean when you click on the user property dropdown in charts, you still see the user property? A screenshot of where you are referring to would be helpful!
Thanks for clearing up the nature of user properties.
I mean when I click into a specific event (to see the user profile I think), the property still shows up. In the screenshot below, I’ve been trying to delete/hide the city property that I created just as a tester.
@carissa.mok Got it! Thanks for sharing that. So this is expected behavior. Deleting a user property will prevent that user property from ingesting moving forward and also remove that user property from being selectable on chart drop downs moving forward. But deleting a user property does not delete historical data hence you will still see the user property on events and user profiles. That said you could remove the user property from appearing on the top half of the user profile (the section you screenshotted) if you unset the user property.
@belinda.chiu Could you clarify what you mean by unsetting the user property in order to remove the property from appearing in the user profile?
@carissa.mok Sure! There are many different kinds of user property operations and of one is simply an unset operation which will allow you to unset and remove the value of the property.
@carissa.mok Ah I see! The setUserProperties is just a wrapper around the set. We do not have a convenience wrapper like unsetUserProperties(<list of strings>) or something that the SDK internally builds an identify call for you, similar to what setUserProperties does.
For unsetting, you will have to call an unset operation via identify.
If you don't have an Amplitude account, you can create an Amplitude Starter account for free and enjoy direct access to the Community via SSO. Create an Amplitude account. You can also create a Guest account below!
If you're a current customer, select the domain you use to sign in with Amplitude.
If you don't have an Amplitude account, you can create an Amplitude Starter account for free and enjoy direct access to the Community via SSO. Create an Amplitude account. Want to sign up as a guest? Create a Community account.
If you're a current customer, select the domain you use to sign in with Amplitude.