Solved

Distinguish user roles using addUserProperties

  • 10 January 2023
  • 2 replies
  • 67 views

Userlevel 3
Badge +5

Hi all,

I created a user property using the following code:

heap.addUserProperties({'user_role': ['admin', 'standard']});

In order to distinguish our platform user roles. Before I was using the following one:

heap.addUserProperties({'user_role': 'admin'});

and I was able to identify admin users. However, I also want to identify the standard ones. Can you confirm the first javascript code is correct? According to the documentation it should work.

After making the changes I'm not getting any data for the last 7 days. Hope you can help me here.

 

Best regards,

Bernardo Madeira

icon

Best answer by Holly Goodliffe 19 January 2023, 22:58

View original

2 replies

Userlevel 2
Badge +2

Thanks for the question Bernardo! I know the Support team is working directly with you on an answer, and they’ll circle back here to share learnings on the Community.

Userlevel 5
Badge +3

@bernardo.madeira The addUserProperties API accepts an object of key:value pairs. Values may be strings or numbers (and lowercase booleans true/false but we just coerce those to strings). We don’t accept arrays. So your example with the array will not work. If for some reason you need to add two different `user_role`s to your users, you should stringify the array. It won’t be an array in Heap, it’ll be a string, but Heap doesn’t currently have analytic support for arrays anyway.

Reply