Tracking Analytics

How It Works

Tracking analytics lets you collect and aggregate user-generated events to evaluate program performance and the number of referrals. The obtained data can be used as an additional way to engage affiliate networks, as strong stats make the offer more attractive.

The following events can be processed:

  • Transition to the landing page
  • Transition from the landing page to the store

Who Can Use It

  • Partners who have Partner Network integrated and an affiliate/affiliate network program configured.
  • Partners who have Partner Network integrated and have free-to-play games

How to Get It

To integrate tracking analytics, do the following:

  1. Get a JSON Web Token (JWT).
  2. Implement the Tracking API methods: create, initialize and send event.
  3. Implement the tracking script on your website.

Getting a Token

HTTP REQUEST

POST https://tracking-api.xsolla.com/v1/tokens

Parameter Description
Authorization API_KEY. You can get your API key from your Publisher Account.
sourceType Data source type. Can be “client”, “server”. Client sources are considered non-trusted, and all respective events in the storage have “trusted: false”. Server sources are considered trusted, and all respective events in the storage have “trusted: true”.
sourceName Data source name.
projectId Project ID.

EXAMPLE: OBTAINING A TOKEN

POST https://tracking-api.xsolla.com/v1/tokens
Authorization: Basic 12kj3hlk1j2hlkjhlk1j2h3lkj
{
  "sourceType": "client",
  "sourceName": "landing",
  "projectId": 1
}

HTTP/1.1 201 Token created
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaW5rIjoiaHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2 g_dj1kUXc0dzlXZ1hjUSJ9.aVigY6UVY3jgoEKoBv31cZnROL3I6WKtcr5K-Z7B1du"
}

Response code Description
201 Token created
400 Query parameters are not valid
401 Project key is not valid

Creating an Event

You need to have obtained a token to do this.

HTTP REQUEST

POST https://tracking-api.xsolla.com/v1/events

Parameter Description
Authorization Previously obtained token.
type Event type.
traits Array. User identification data: phone, email, in-game ID, etc.
context Array. Contextual data.
properties Array. Event properties.
createdAt Date. Format: datetime per RFC 3339 or ISO 8601.

EXAMPLE EVENT: TRANSITION TO LANDING PAGE

POST https://tracking-api.xsolla.com/v1/events
Authorization: Bearer
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaW5rIjoiaHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g_d j1kUXc0dzlXZ1hjUSJ9.aVigY6UVY3jgoEKoBv31cZnROL3I6WKtcr5K-Z7B1yU
{
  "type": "landing_visit",
  "traits":{
    },
  "properties":{
    },
  "context": {
    "user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36", "user_locale":"ru"
  }
}

EXAMPLE EVENT: TRANSITION TO PAY STATION

POST https://tracking-api.xsolla.com/v1/events
Authorization: Bearer
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaW5rIjoiaHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g_d j1kUXc0dzlXZ1hjUSJ9.aVigY6UVY3jgoEKoBv31cZnROL3I6WKtcr5K-Z7B1yU
{
  "type": "buy_btn",
  "traits":{
    },
  "properties":{
    "pkg_type":"bronze"
    },
  "context": {
    "user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36", "user_locale":"ru"
  }
}

Response code Description
204 Event added
400 Event is not valid
401 Token is not valid

Initializing an Event

You need to have obtained a token to do this.

xnt("init", YOUR_TOKEN);

Sending an Event

xnt("sendEvent", EVENT_TYPE, EVENT_PROPERTIES);

Parameter Description
EVENT_TYPE Event name (string). E.g., “landing_visit”.
EVENT_PROPERTIES Event properties (JS object).

Example

xnt("sendEvent", "landing_visit");
xnt("sendEvent", "buy_btn", { pkg_type: $(this).data('id') });

EVENT PARAMETERS

Parameter Description
source Event source (paystation, landing_page, etc.).
type Event type (user_visit, hit, etc.).
traits User data (email, user_id, nickname, etc.).
context Event context (ip, gaClientId, etc.).
properties Event properties (sum, levelup, etc.).
createdAt Event time, as passed by the source.
timestamp Time of event receipt by the system.

To complement the event with ‘context’ & ‘traits’ parameters, use the following methods:

xnt("putContext", CONTEXT_OBJECT);
xnt("putTraits", TRAITS_OBJECT);

Parameter Description
CONTEXT_OBJECT Event context (JS object).
TRAITS_OBJECT User data (JS object).
Note: Context’s ‘userAgent’ and ‘userLocale’ will be added automatically. The data added by these two methods will be combined with the event data.

Implementing the Script

Implement the following script on the landing page:

<script>
(function(i,s,o,g,r,a,m){i['XsollaNetworkTrackingObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(ar guments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.inse rtBefore(a,m)})(window,document,'script','https://cdn.xsolla.net/network/xtracking-0.1.js','xnt');
xnt("init", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaW5rIjoiaHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g_ dj1kUXc0dzlXZ1hjUSJ9.aVigY6UVY3jgoEKoBv31cZnROL3I6WKtcr5K-Z7B1du");
xnt("sendEvent", "buy_btn", { pkg_type : "gold" });
</script>