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. Save tracking_id from the request parameter to your website cookies. Example of a request with tracking_id: https://playnewz.com?utm_source=n6LI9yVu&utm_campaign=5b9bff5f9d31b&tracking_id=19e2DLjNTk2YOdXA4d8J3NReNkXNafhC.
  3. After a new user is created, send user_id and tracking_id via Registration Event Sending method.
    • We recommend you send requests asynchronously, so it doesn't interfere with user registration while awaiting the Xsolla Tracking API response.
    • Otherwise, use timeout. Note that new users won't be tracked if awaiting the Xsolla Tracking API response takes longer than specified.
  4. To create and manage custom events, implement the following Tracking API methods: create, initialize and send event.
  5. Implement the tracking script on your website.

Getting a Token

HTTP REQUEST

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

HeaderDescription
ContentTypeapplication/json
AuthorizationBasic your_authorization_basic_key. Required.
your_authorization_basic_key is merchant_id:api_key parameter pair coded according to the Base64 standard. You can find values for merchant_id and api_key in your Publisher Account:
  • merchant_id: Company settings > Company > Merchant ID
  • api_key: Company settings > API key
ParameterDescription
sourceTypeData source type. It can take the following values:
  • client. This source type is considered non-trusted, and all respective events in the storage have the status trusted: false.
  • server. This source type is considered trusted, and all respective events in the storage have the status trusted: true.
sourceNameData source name.
projectIdProject ID.

EXAMPLE

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

Headers:
Content-Type: application/json
Authorization: Basic 12kj3hlk1j2hlkjhlk1j2h3lkj 

Body:
{
  "sourceType": "client",
  "sourceName": "landing",
  "projectId": 1
}

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

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

Registration Event Sending

You need to first obtain a token to do this.

HTTP REQUEST

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

While sending the method, the following steps are completed:

  1. The end user follows the tracking link they found on the traffic source (influencer's stream, promo page, etc.). The action is given its Click ID.
  2. Tracking ID is formed on the Proxy page side and passed to the landing page in the parameter.
  3. The user visits the landing page and signs up.
  4. The game developer passes user User ID and Tracking ID in the parameter by sending the registration event via Tracking API.

ParameterDescription
AuthorizationPreviously obtained token.
typeEvent type (here: registration).
traitsObject. User identification data:
  • trackingId – Tracking ID of the user redirected to the game website. Xsolla sends it in the request parameter after the redirect.
  • userIduser ID assigned upon token creation.
contextThe object must be empty.
propertiesThe object must be empty.

EXAMPLE

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

Headers:
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaW5rIjoiaHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g_d j1kUXc0dzlXZ1hjUSJ9.aVigY6UVY3jgoEKoBv31cZnROL3I6WKtcr5K-Z7B1yU 

Body:
{
  "type": "registration",
  "traits": {
    "trackingId": "19e2DLjNTk2YOdXA4d8J3NReNkXNafhC",
    "userId": "20181126"
  },
  "properties": {
  },
  "context": {
  }
}'

Creating an Event

You need to first obtain a token to do this.

HTTP REQUEST

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

ParameterDescription
AuthorizationPreviously obtained token.
typeEvent type.
traitsObject. User identification data: phone, email, in-game ID, etc.
contextObject. Contextual data.
propertiesObject. Event properties.
createdAtDate. Format: datetime per RFC 3339 or ISO 8601.

EXAMPLE EVENT: TRANSITION TO LANDING PAGE

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

Headers:
Content-Type: application/json
Authorization: Bearer
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaW5rIjoiaHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g_d j1kUXc0dzlXZ1hjUSJ9.aVigY6UVY3jgoEKoBv31cZnROL3I6WKtcr5K-Z7B1yU 

Body:
{
  "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

Headers:
Content-Type: application/json
Authorization: Bearer
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaW5rIjoiaHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g_d j1kUXc0dzlXZ1hjUSJ9.aVigY6UVY3jgoEKoBv31cZnROL3I6WKtcr5K-Z7B1yU 

Body:
{
  "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 codeDescription
204Event added
400Event is not valid
401Token is not valid

Initializing an Event

You need to first obtain a token to do this.

xnt("init", YOUR_TOKEN);

Sending an Event

xnt("sendEvent", EVENT_TYPE, EVENT_PROPERTIES);

ParameterDescription
EVENT_TYPEEvent name (string). E.g., "landing_visit".
EVENT_PROPERTIESEvent properties (JS object).

EXAMPLE

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

EVENT PARAMETERS

ParameterDescription
sourceEvent source (paystation, landing_page, etc.).
typeEvent type (user_visit, hit, etc.).
traitsUser data (email, user_id, nickname, etc.).
contextEvent context (ip, gaClientId, etc.).
propertiesEvent properties (sum, levelup, etc.).
createdAtEvent time, as passed by the source.
timestampTime 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);

ParameterDescription
CONTEXT_OBJECTEvent context (JS object).
TRAITS_OBJECTUser 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>