Skip to main content
Solved

Best way to structure Monthly Activities count as User Properties?

  • May 9, 2022
  • 1 reply
  • 393 views

sagarsoni7

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?

Best answer by Saish Redkar

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.

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

1 reply

Saish Redkar
Expert
Forum|alt.badge.img+10
  • Expert
  • 1377 replies
  • Answer
  • May 9, 2022

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


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