Skip to content

Tracking code

Cristina Alonso edited this page Nov 5, 2018 · 17 revisions

The tracking code is provided when the developer registers a new game (via the front-end) and is used to link a player with a given game version. We use the tracking code to identify the data stored in each collection. Both games and activities have their own tracking codes.

To be able to correctly send data to the collector endpoint you must follow these steps:

  1. Issue a POST localhost:3000/api/proxy/gleaner/collector/start/:trackingCode with the provided tracking code. The response will contain the authorization token (authToken) needed to identify the following requests.
  2. Issue POST localhost:3000/api/proxy/gleaner/collector/track with an authorization header (<Authorization:authToken>) and your tracking data inside the body of the request following the xAPI statement JSON format.

Setting up the tracking code

The rage-analytics tracker automatically issues a request to the collectorHost/start/:trackingCode in order to receive an authorization token used to identify the client.

In the game LostInSpace the collectorHost and the trackingCode are automatically parsed from this file with the format collectorHost;trackingCode. This means that in order to set up the trackingCode all you need to do is edit this file with the value of the collectorHost provided when registering the server-side application rage-analytics back-end and the trackingCode provided when creating a new game.

Figure 1.: tracking code for Lost in Space game, obtained from the developer configuration page.

Note that the trackingCode is obtained by issuing a GET API call to /api/games/:gameId/versions/:versionId which returns the following response:

{
    "_id": "559a447831b76cec185bf513",
    "gameId": "559a447831b7acec185bf513",
    "trackingCode": "575acfd9557ab538177a958awbg5le01tzh93sor"
}
Clone this wiki locally