The AccelByte Statistics service provides a straightforward way to have persistent statistics tracking for your users. The statistics data is associated with individual user accounts, and can be used as a reference for further integration to other AccelByte features such as Leaderboards, Achievements, Matchmaking, and Rewards.
By tracking user statistics as references, you can enable many other features.
- A leaderboard that tracks users' total number of wins.
- Achievements that track how many times an item has been consumed.
- Matchmaking rulesets that group users based on their MMR score.
- Triggering an in-game item reward when the user reaches a certain level or points score.
There are also many other different scenarios that you can explore to support user engagement in your game.
In the next section you will learn about the key concepts related to the Statistics service, the supported features, and additional possible uses for the service, including some best practices.
To make sure you can have seamless integration with the Statistics service, it is important to understand some of the key concepts that have been used in the design of the service.
Statistics configuration provides a set of rules that apply to each statistic. Each statistic configuration allows you to set up a unique string to identify the statistic, such as the minimum value allowed, the maximum value allowed, and other settings.
Instead of using a machine generated code, Stat Code is a unique string, used to identify a statistic associated with a user. This is so developers can easily track and use it, for example:
Global statistics is an accumulated value from all contributing users to a statistic. You can choose to configure a statistic as a global statistic to track game wide contributions from all users. For example, when you set a
total-matches-played stat as a global statistic, it will not only track the
total-matches-played for each user, but also the
total-matches-played for all users combined.
There are multiple different value concepts within Statistics:
Default value This is the starting value that is assigned to the user statistic. For example, if you set the default value of
experience-pointsto 0, all of the users registered to the platform will start with
experience-points = 0.
Minimum and Maximum value These are the minimum and maximum values allowed for each statistic. User statistics will not be able to exceed the minimum and maximum value set for the configuration. You can also configure negative values, if needed.
This is a feature to prevent the statistic from going down. It gives extra server side validation that is suitable for tracking statistics that only allow an increasing value over time.
This is a feature to let you decide whether a statistic can only get updated by a game server, or game client. When it is set to server, additional server-side validation is enabled to prevent the statistic from getting updated directly from the game. This can help prevent cheating.
This is a status that is used to track whether a statistic configuration is already used by a user or not. Once the statistic is used, the status will change to
tied, and cannot be deleted.
User Statistics Update and Integration Flow
This section explains how the user statistic is updated and integrated with other AccelByte services. Understanding the flow will make it easier for you to understand how to best utilize the service.
User statistics can be updated from both the game client and game server. You can choose to add extra validation using the Set By feature.
Every time a user statistic is updated, the service will fire events that are used by other AccelByte services to do further actions, such as unlocking achievements, granting items, and so on.
The best scenario to use the Statistics service is when:
- You need a consistent, persistent and safe way to track user statistics.
- You need to track the statistics for other purposes such as leaderboard ranks, matchmaking, achievements, etc.
Note that each statistic needs to be configured separately, therefore, it might not be suitable if you need to store considerable amounts of player attributes such as player skill attributes.
If you do not require to track the statistic for further integration and only need a storage solution to store player attributes, you can utilize the Cloud Save service.