Solved

Best way to structure Monthly Activities count as User Properties?

  • 9 May 2022
  • 1 reply
  • 192 views

I have user’s monthly activities in this format:

{
"2022": {
"5": {
"Likes": 2,
"Comments": 1
}
}
}

If I sync this as user attributes, how would I be able to get answers to questions like:

  • Which activity is more popular among all users? [Likes or Comments?]
  • How many total Likes were performed by given user in whole year 2022?

Is this possible in Amplitude?

icon

Best answer by Saish Redkar 10 May 2022, 01:43

View original

1 reply

Userlevel 7
Badge +10

Hey @sagarsoni7 

There are many approaches to this depending on your use case.

IMO, the nested JSON approach is always be a tricky one for extracting the right datapoint. You can refer to this post for added context.

If you do use a nested json object property, you can try leveraging the EXTRACT_FROM_DICT function in the derived properties feature to create properties on the fly based on a specific key value if that appears useful. Assuming the ‘5’ is the month of May in your format, you can breakdown this as user_likes_May

  • Which activity is more popular among all users? [Likes or Comments?]
    • Do you have events for when a user likes or comments something ? IMO, the event counts comparison between these 2 events over a time period will give a better measure of answering this question as compared to your current format.
  • How many total Likes were performed by given user in whole year 2022?
    • You can also have the total count for likes/comments updated for a user as and when they perform this event and update them as two separate user properties. Your current format has the monthly breakdown which can make it a bit weird to query. Amplitude has a Computations feature where you can create this counter on the fly based on the specified event counts, but I believe this one is a paid one via Recommend. Two things can be done here -
      • An event seg chart on the like event and then total count over the year for that user
      • User composition chart for the like_count user property where you can segment on the most recent value for that user/s.

Let me know if I have interpreted your use case correctly. Hope this helps.

Reply