Skip to content

Statistics and Achievements

The GOG GALAXY SDK allows to store information about statistic and achievements using the IStats interface.

Before working with achievements, you must define them in the Developer Portal. To add achievements, go to Games, click the Galaxy Features button for a game and select Achievements from the resulting list:

Galaxy Features Button

Alternatively, if you have all achievements already deployed on Steam, you can import them to GOG Developer Portal by following this guide.

Important

When working with GOG GALAXY stats or/and achievements, please remember to have them retrieved first with RequestUserStatsAndAchievements(), and that you have to call the StoreStatsAndAchievements() function after changing a statistic value or achievement state to make this change persistent (see the section below).

Setting a User Achievement/Statistic

To unlock an achievement or change a statistic value, you need three methods:

  1. IStats::RequestUserStatsAndAchievements() — to retrieve user’s statistics and achievements.
  2. IStats::SetAchievement() or IStats::SetStatFloat()/SetStatInt() — to unlock achievements and set statistics values, respectively. Achievement name provided as an argument to the SetAchievement() function is the same as the one specified in the “API_KEY” field in the Developer Portal.
  3. IStats::StoreStatsAndAchievements() — this method pushes information about unlocked achievements and changed stats to the GOG GALAXY backends.

Before calling the Set or Store methods, please remember to wait until success response comes from RequestUserStatsAndAchievements() to UserStatsAndAchievementsRetrieveListener.

Offline Achievements and Statistics

Offline achievements/statistics will work automatically in the same way as they do in an online mode. If achievements are implemented properly, they will be unlockable even when the user is offline, but was signed in to Galaxy client before losing Internet connection. After unlocking an achievement, the notification about this event will be shown (if the Galaxy Overlay is turned on) and statuses of achievements and new values of statistics will be aggregated in order to synchronize them with the GOG GALAXY backends as soon as the user is back online.

Important

Please remember that IsLoggedOn() (which gives info about the connection to the Galaxy backend) returns True for an online mode and False for an offline mode, so you shouldn’t disable Achievements and Statistics features based on this status.

Achievements Modes

When the achievements mode is set to Production in the Developer Portal, all achievements are visible to end users. Achievements without the flag “Is visible before unlocking” turned on will show up as a “Secret Achievement” in the GOG GALAXY client.

Achievements Modes in Developer Portal

In the Development mode, no achievements are displayed in the GOG GALAXY client and only appear when a user fulfils the unlock criteria for them in an SDK-integrated build. This allows you to work on your achievements without end users seeing them. Please note that achievements will always be visible if they are unlocked.

Clearing Achievements

During development, you might be interested in clearing achievements progress for testing purposes. In order to reset achievements state, you can call the ClearAchievement() function, passing an API key of an achievement as the argument. Please remember that first you have to retrieve achievements with the RequestUserStatsAndAchievements() function and call the StoreStatsAndAchievements() function after clearing an achievement to make this change persistent.

Setting Up Achievements Does Not Work — What Should I Do?

For more information about Achievements and their related GOG GALAXY SDK methods, please visit the GOG GALAXY SDK API documentation.

Back to top