Terry Kwon avatar image
Terry Kwon asked

Leaderboard based on Location (Country)

Is it possible to rank countries based on user location so that I can show users which country is doing the best and encourage them to play more for their country. Can I use current leaderboard system? or is there any other way to achieve the goal like using shared group data?


Leaderboards and Statistics
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

We'll be providing additional ways to filter leaderboard results in a future update, but for right now, you would need to use separate statistics for each geographic region you want to be distinct. But adding players to the appropriate leaderboard would be relatively simple, as we provide geographic information in the results of the login call, which you could use to decide which leaderboard to use for that player (either basing it on their first login, or else moving them based on their current login).

And no, Shared Group Data is intended for sharing some data between a small number of players, like the persistent state of an asynchronous turn-based game. It cannot be used to drive a leaderboard.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Terry Kwon avatar image Terry Kwon commented ·

Hi Brendan, Thanks for your quick reply.

However, it is my bad that I didn't explain clearly. What I want to achieve is something like this:

1 Like 1 ·
leaderboard.png (338.7 KiB)
brendan avatar image brendan Terry Kwon commented ·

Oh! Yes, that's much easier - all you need to do is specify what elements of the profile you want to get back for each player (have a look at the ProfileConstraints parameter). You can get many elements, including the location of login, as well as other statistics. Please note however, that you do need to explicitly enable these in your game's settings, if you want to get them from a Client API call.

0 Likes 0 ·
Terry Kwon avatar image Terry Kwon brendan commented ·


So what you mean is I have to make leaderboards for each country and that is max 25 countries at the moment for free tier, right?

0 Likes 0 ·
Show more comments
Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

A bit late to the party here, but I'm looking to implement the same thing (rank countries by aggregate statistics).

Would it work if I have a mock user account for each country, such as "leaderboard_us" for US stats, then update that mock account's stats every time I update stats for someone from that country?

In essence, a frequently-updated running total, rather than aggregating stats from multiple users.

Then to display these scores on the client, I'd query the stats for all the special "country" user and sort them based on scores.

Edit: Idea number 2 would be having a Scheduled Task to run every 24 hours and iterate through the All Players segment and update the stats (of mock users) accordingly. This would be more accurate than the above, although it could place some strain on the system to iterate through all players every 24 hours.

0 Likes 0 ·
brendan avatar image brendan Brent Batas (Lisk) commented ·

No, trying to write to a single value from all players (or a segment like that) in the current statistics model will not work. It would generate a large number of change operations against a single row in a data table in a short period, which would cause the table's access times to spike. As a result, we'd be forced to block the title, to prevent the issue - so clearly not something you'd want to do. Right now, you would need to use an external data store (such as Redis).

We are working on an updated data model which will allow for many players to operate on shared data, specifically to provide a supported model for guilds/team/clans. Once that's in place, it may provide you with additional options - keep an eye on our blog for that update. :)

0 Likes 0 ·
Brent Batas (Lisk) avatar image Brent Batas (Lisk) brendan commented ·

I see - thanks for the response. I am glad I asked first before trying it.

Would this updated model work for potentially tens of thousands of players per country? (Just thinking potential numbers here)

0 Likes 0 ·
Show more comments
alexeygr avatar image alexeygr commented ·

Hi, 3 years have passed since the question. What changes have been made in the PlayFab during this time to resolve this issue by country grouping?

0 Likes 0 ·
brendan avatar image brendan alexeygr commented ·

Decisions on scheduling for work comes down to priority, which is not driven by when an item is added to the backlog. It's driven by strategic priorities and the aggregated feedback from our community. While we've had a few requests for this, it hasn't been nearly as asked for as other features, which were necessarily ahead of it in line since then. Fortunately, our updated statistics/leaderboard system will enable this capability. That'll be available later this year, as shown in our roadmap:

0 Likes 0 ·
ryan-5 avatar image
ryan-5 answered

Hey @Brendan, Has this been completed?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.