Starting Leaderboards at Zero Each Day, Week, Month, or Year

We're often asked how to track a player's maximum score in for each day/week/month. Using a Leaderboard that resets daily/weekly/monthly won't achieve this - see Reset Frequency on the main Leaderboard Configuration page. This is because when you configure a Leaderboard to reset, the Leaderboard will reset the entries but not the underlying Running Total data. So, if I scored 50 on day one, I would need to score >50 on day two to register a new high score. However, you can make use of Leaderboard partitions to start from zero each day.

This tutorial explains how you can set up your Leaderboards to start from zero each day/week/month/year - there are three steps we'll complete:

Creating an Event for a Running Total with a Date Formatted Attribute

Here's an example of an Event configuration you can use for driving time-partitioned Leaderboards, and which is intended to illustrate the kind of Grouped Attributes you'll need to meet this use case for resetting Leaderboards on a daily/weekly/monthly basis.

In this example, the important thing to note are the expressions used for the Default Values of the Event's day/week/month/year Attributes. Take the day Attribute - because we've used this type of generalized expression as the Default Value for the day Attribute, it will automatically be added in accordance with this format in the partition. For example, for January 25th it will be added as 01-25. For the next day, January 26th, it will be added as 01-26, and so on. To read more about the supported expressions, please see the section on Expressions here.

Configuring a Partitioned Leaderboard Using a Running Total with a Time-Based Grouped Attribute

An example of a day Leaderboard configuration is given below. Note that we are partitioning on the day Attribute we set up for the leaderboard_Time Event's configuration. You can also create separate Leaderboards for week, month, and year in a similar way. If you do this, remember to swap out the partitioned value for the time period on which you want to partition your Leaderboard - week for week, month for month, and so on.

Checking Leaderboard Configuration in the Test Harness

Now you can submit a score in the Test Harness and test your configuration. Authenticate as a player and then send your score Event. Note that a value for the day Attribute doesn't need to be added in the request, because it's handled by the Default Value we set in the Event:

{
"@class": ".LogEventRequest",
"eventKey": "leaderboard_Time",
"score": 60
}

You should get a NewHighScoreMessage like the one below:

As you can see, the leaderboardShortCode is LB_DAY.day.01-25. Tomorrow it will be LB_DAY.day.01-26 and so on. This is the best way to implement this system. You'll likely need to change the logic for retrieving the Leaderboard's data on the client side to accommodate this.

Did this page help you? Please enter your feedback below.