Last Updated: 11/30/2021, 10:01:19 AM

# Statistics

# Overview

The Statistics service provides game developers with persistent statistic tracking for their games. Tracked statistics include gameplay-related stats such as kill, die, and assist, and internal game data such as map played and game modes played. Statistics are tied to players and can be easily integrated or displayed as game profile attributes through the game profile service.

The statistics service also acts as the reference point for consistent value tracking across other services such as Progression, Achievements, and Leaderboards. We use messaging to update statistics values asynchronously to other related services in real-time. You only need to define the statistics you want to measure once, and they’ll be applied to all related services.

# Permissions

Permissions are used to grant access to specific resources within our services. Make sure your account has the following permissions before you attempt to manage statistics in the Admin Portal:

Usage Permission Tag Action
Create a New Statistic Configuration ADMIN:NAMESPACE:{namespace}:STAT Create
Create a Single Statistic for a Player ADMIN:NAMESPACE:{namespace}:USER:{userId}:STATITEM Create
Create a Multiple Statistics for a Player ADMIN:NAMESPACE:{namespace}:USER:{userId}:STATITEM Create
Retrieve All of a Player’s Statistics ADMIN:NAMESPACE:{namespace}:USER:{userId}:STATITEM Read
Update a Single Statistic for a Player ADMIN:NAMESPACE:{namespace}:USER:{userId}:STATITEM Update
Update Multiple Statistics for Multiple Players ADMIN:NAMESPACE:{namespace}:USER:{userId}:STATITEM Update
Retrieve Global Statistics ADMIN:NAMESPACE:{namespace}:USER:{userId}:STATITEM Read

Permissions work slightly differently depending on whether they are assigned to IAM Clients or Roles assigned to users. For more information, read the Authentication and Authorization documentation.

# Managing Statistics in the Admin Portal

# Create a New Statistic Configuration

  1. In the Statistics section of the Admin Portal, open the Configurations menu.

    cloud-save

  2. In the Statistic Configurations window, click the Add Configuration button.

    cloud-save

  3. Fill in the required fields.

    cloud-save

    • Input the statistic code in the Code field, following the formatting rules given.
    • Input the Name of the configuration.
    • Input a Description of the configuration. This field is optional.
    • Define the minimum value of the statistic in the Min. Value field.
    • Define the maximum value of the statistic in Max. Value field.
    • Input the Default Value of the statistic.
    • Choose the Increment value. If set to true, the stat value can only be increased. If false, the stat value can be increased or decreased.
    • Choose the Set As Global value. If set to true, every time the stat is updated the global stat value will also be updated.
    • Select the Set By value. You can select either the game client or game server. This determines which client will update the stat value.
    • Input the Tag field with contextual information related to the statistic. This field is optional.

# Retrieve Global Statistics

  1. In the Admin Portal, click the Statistics Value menu.

    cloud-save

  2. Switch to the Global tab. Here you’ll see the global statistics.

    cloud-save

# Implementing Statistics Using the SDK

# Create a Single Statistic for a Player

You can use SDK to create a statistic for a player from your game server by following the example below.

# Create Multiple Statistics for a Player

To create statistics for a player in bulk, follow the example below.

# Retrieve a Player’s Statistic by StatCode

This example will only retrieve a player's statistic for the specified statCode in a game namespace.

# Retrieving a Player’s Statistic by Tag

This example will only retrieve a player's statistic for the specified tag in a game namespace.

# Update Multiple Statistics for a Player

This example is used to update multiple statistics for a player simultaneously.

# Update Multiple Statistics for Multiple Players

This example is used to update multiple statistics for multiple players simultaneously. This update must be authorized by a user with higher privileges, such as an admin.