Sending Statistics
Any event in your game can be submitted to Kongregate. Then we can use those to make badges, and display leaderboards.
All statistics must be non-negative integers. So, 0, 42, and 613341 are all fine, but -5 and 1.542 won't work. If you have a carefully timed game that records milliseconds, you'll want to multiply the time by 1000 when submitting to our server. So 1.542 seconds would need to be submitted as 1542 milliseconds.
Types
- Max: The value on the server will be replaced if the new value is higher, for example a high score.
- Min: The value on the server will be replaced if the new value is lower, for example the lowest time for completing a lap.
- Add: The new value will be added to the value stored on the server, for example total number of coins collected. This can be used for statistics which are cumulative.
- Replace: The new value will always overwrite the value on the server, this can be useful for statistics that need to go either up or down, such as a player ranking.
Creating your statistics
After you come up with your list of statistics, you need to set them up on the server. This can be done by adding /statistics onto the URL for your game in your browser window. For example: http://www.kongregate.com/games/BenV/my-game/statistics This will take you to the statistics editor page, which can only be viewed by the owner of a game. Note: You can also view the statistics editor on the edit game page.
Give each statistic a name, description, and choose it’s type. You can also select statistics you wish to show up in the leaderboards by checking the "Display in Leaderboards" option.
Once you have created all your statistics on the server, it is time to integrate the API into your game.
Submitting statistics
You can use either the Client or Server API to submit statistics to the server:
Getting the most out of the API
If you would like your game to get badges or be part of a challenge, make sure to read these statistics integration tips written by Greg, lead creator of badges/challenges.
Comments