Skip to main content

We would like to use an array to capture unique tag values on our user properties like a traditional set. We have a finite set of values but do not know what values have previously been sent to Amplitude from the client.

We are using the .append() method to add the tags to the array and have checked “unique values” in the Data tool on the user property. However, this does not prevent duplicate tags from being inserted into the user property. e.g when appending tag “a” multiple times, we end up with multiple “a” entries on the user property array.

Is there a way to enforce unique values in this user property array?

I have tried sending a remove followed by an append on the same call, but the SDK drops the append as the property name has already been used:

Identify().remove(“tags”, “a”).append(“tags”, “a”

I could send two identify calls in quick succession with the first being the remove and the second an append, but I am not sure if Amplitude processing will always process these identify calls in the right order. Can I safely do this?

 

Hi @msanders ,

 

Thanks for writing in! You could use preInsert and postInsert if you wish! They are described in the doc here. These will pre or post Insert items into your array but will only add the ones that do not exist and show, this should keep the entries unique. Be sure to test it with a dummy user first! 

Kind Regards,
Denis


Aha! Looks like I should have upgraded from the legacy Browser API as there is a solution!

Fantastic, thank you Denis.


Reply