Was this article helpful?

Leaderboard

Last modified 05:33, 13 May 2014

 

Note: Game Mechanics is a premium platform that requires separate activation. If Game Mechanics is not part of your site package please contact your Gigya account manager or contact us by filling in a support form on our site. You can also access the support page by clicking "Support" on the upper menu of Gigya's site.

 

Introduction

The Game Mechanics (GM) Leaderboard plugin displays the top ranking users in a specific challenge. Note: the leaderboard will only display users who have a name, email or provider. 

Each site may have one or more challenges, and each challenge has defined levels. Each level has a badge associated with it, and a level title. A user may achieve a level in a certain challenge by performing actions and accumulating points for these actions. The user's points can then be used to calculate the user's rank compared to the rest of the challenge's users. To learn more about Gigya's Game Mechanics, refer to our Game Mechanics Guide.

The Leaderboard plugin displays a predefined number of users, each with their photo, name, and rank. The top three users also have a medal icon:

gm_leaderboard.gif

In a logged-in state, the Leaderboard display is made up of three kinds of users:

  • The current logged-in user, regardless of his rank. If his rank is insufficient to make the leaderboard, he replaces the last user to make the leaderboard.
  • Up to a specified number of friends of the current user, regardless of their rank
  • The rest are the top ranking users for the specified challenge who have public profiles

In a logged-out state the leaderboard plugin just displays the highest ranking users.

 

In addition to the initial plugin display, you can click on any of the users to open an info popup:

gm_leaderboard_popup.gif

The info popup displays the user's:

  • Name
  • Photo
  • Points - either the total points, or the points accumulated over the past seven days for the specific challenge (as defined in gm.showLeaderboardUI)
  • The specified challenge's level badge and title
  • Achievements in other challenges, represented by the achieved level's badge and title

 

Quick Start Implementation

Implementation Overview

Adding the Leaderboard plugin is simple, and involves only adding a few lines of code:

  • Step 1: Define the section (div) where the Leaderboard plugin should be embedded
     
  • Step 2: Define the Leaderboard plugin's parameters.

 

 

Code Example

Add the following code snip to the <body> of your page to activate the Leaderboard plugin:

<div id="divLeaderboard"></div>

<script>
    var leaderboardParams = {  
            containerID: 'divLeaderboard'  
    }  
    gigya.gm.showLeaderboardUI(leaderboardParams);  
</script>

 

Code Explanation

Step 1: Define the Leaderboard plugin's div

<div id="divLeaderboard"></div>

 

Step 2: Define the Leaderboard plugin parameters

var leaderboardParams = {  
        containerID: 'divLeaderboard'  
}

The Leaderboard plugin has one required parameter:

  • containerID - the identifier of the DIV element, where the Leaderboard plugin should be embedded.

In addition there are a few optional parameters. Please refer to the method's parameters table for the entire list of optional parameters.

 

Step 3: Invoke the Leaderboard plugin

Call the gm.showLeaderboardUI API method:

gigya.gm.showLeaderboardUI(leaderboardParams);

Like every Gigya API method, the gm.showLeaderboardUI API method receives one parameter - parameters object, which is the object we have defined in Step 2 (learn more about Gigya's basics here). 

 

Tie Breaking

Leaderboard ties are resolved according to who achieved the points first; if player A and player B both have 60 points, and player A reached 60 points before player B, then player A will be before player B on the leaderboard.

 

A Working Example

In the GM Plugins demo you will find a complete working example of a web-page that uses all GM plugins, including the Leaderboard plugin. You may view the code, run it and view the outcome.

Was this article helpful?
Pages that link here
Page statistics
5554 view(s) and 6 edit(s)
Social share
Share this page?

Tags

This page has no custom tags set.

Comments

You must to post a comment.

Attachments