Skip to main content
Solved

Get user properties in Javascript SDK


Is it possible to get user properties or just set them? I’m currently using `Identify().append()` to add Optimizely experiment IDs to an `experiments` property, but if a user visits the same page, that experiment is added to the array again. I’m trying to figure out how I can avoid duplicating items in the array.

Best answer by Zhenia Semenina

You could try to make a call using User Profile API and check properties assigned to a specific user.

Read more on it here: 

https://www.docs.developers.amplitude.com/analytics/apis/user-profile-api/#get-user-properties 

 

 

I would not be able to provide exact code snippets but maybe someone on the forum implemented something like this in the past? Would love to hear your experience! 

 

Best,

Zhenia

View original
Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img+7

Hey there,

Thanks for writing in! 

We use Identify to work with user properties and currently this is indeed the best way to update / edit/ set user properties. 

 

To avoid duplication you could try and build some internal logic in your code that would check current items in the array and only append a new one if it does not exist yet (e.g if...else)

 

That’s what comes to mind! 

 


  • Author
  • New Member
  • 1 reply
  • August 11, 2022

@Zhenia Semenina That’s exactly what I had in mind, but couldn’t figure out how to access the current items in the array. Is there a method for that? All I’ve seen in the docs is setters, no getters.


Forum|alt.badge.img+7

You could try to make a call using User Profile API and check properties assigned to a specific user.

Read more on it here: 

https://www.docs.developers.amplitude.com/analytics/apis/user-profile-api/#get-user-properties 

 

 

I would not be able to provide exact code snippets but maybe someone on the forum implemented something like this in the past? Would love to hear your experience! 

 

Best,

Zhenia


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings