Store Additional Data On Leaderboard
A Leaderboard currently only support storing a single value as score, so if you want to show additional information in your leaderboard we have a couple of ways that will allow you to do that depending on what data you want to show.

Sortable data

If you want to store additional sortable numeric data like accuracy, targets hit etc. we suggest you create additional leaderboards for each of these metrics and then merge them when showing the data to users. Depending on what is being sorted you call that leaderboard using the /list endpoint and then decorate the returned data using data from the second leaderboard using the /members endpoint.
Example
We want a leaderboard with the following data: score and accuracy. Create 2 leaderboards: score_leaderboard and accuracy_leaderboard
The default sorting is by score, so when we want to display the leaderboard in the game we first call /list?count=100 to get the top players on the score leaderboard.
After getting the result we can then decorate the data from the accuracy leaderboard using the /members endpoint. Call that with members returned in the first call to /list and then merge the data.
If the user then sorts by accuracy we simply reverse the order of calls, so first we use the /list endpoint for accuracy and then decorate with the /members endpoint calling the score leaderboard.

Non sortable data

For player type leaderboards it's possible to simply store data on each player. As long as it's in the public data on the player it will be returned when getting ranks automatically.
If you're using the generic type leaderboard and want to store additional non sortable data, currently the only solution is to manually enrich the leaderboard data with a separate data source.
Last modified 5mo ago
Copy link