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
How to get it
To integrate tracking analytics, do the following:
- Get a JSON Web Token (JWT).
- 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.
- After a new user is created, send user_id and tracking_id via the Registration Event Sending method.
- It's recommended to 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.
- To create and manage custom events, implement the following Tracking API methods: create, initialize and send an event.
- Implement the tracking script on your website.
Getting a token
HTTP REQUEST
- http
POST https://tracking-api.xsolla.com/v1/tokens
Header | Description |
---|---|
ContentType | application/json |
Authorization | 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:
|
Parameter | Description |
---|---|
sourceType | Data source type. It can take the following values:
|
sourceName | Data source name. |
projectId | Project ID. |
EXAMPLE
- http
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 code | Description |
---|---|
201 | Token created |
400 | Query parameters are not valid |
401 | Project key is not valid |
Registration event sending
You need to first obtain a token to do this.
HTTP REQUEST
- http
POST https://tracking-api.xsolla.com/v1/events
While sending the method, the following steps are completed:
- 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.
- Tracking ID is formed on the Proxy page side and passed to the landing page in the parameter.
- The user visits the landing page and signs up.
- The game developer passes user User ID and Tracking ID in the parameter by sending the registration event via Tracking API.
Header | Description |
---|---|
Authorization | Previously obtained token. |
Parameter | Type | Description |
---|---|---|
type | String | Previously obtained token. |
traits | Object | User identification data:
|
context | Object | Must be empty. |
properties | Object | Must be empty. |
EXAMPLE
- https
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
- http
POST https://tracking-api.xsolla.com/v1/events
Header | Description |
---|---|
Authorization | Previously obtained token. |
Parameter | Type | Description |
---|---|---|
type | String | Event type. |
traits | Object | User identification data: phone, email, in-game ID, etc. |
context | Object | Contextual data. |
properties | Object | Event properties. |
createdAt | Date | Format: datetime per RFC 3339 or ISO 8601. |
EXAMPLE EVENT: TRANSITION TO LANDING PAGE
- http
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
- http
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 code | Description |
---|---|
204 | Event added |
400 | Event is not valid |
401 | Token is not valid |
Initializing an event
You need to first obtain a token to do this.
- html
xnt("init", YOUR_TOKEN);
Sending an event
- html
xnt("sendEvent", EVENT_TYPE, EVENT_PROPERTIES);
Parameter | Description |
---|---|
EVENT_TYPE | Event name (string). E.g., "landing_visit". |
EVENT_PROPERTIES | Event properties (JS object). |
EXAMPLE
- html
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' and 'traits' parameters, use the following methods:
- html
xnt("putContext", CONTEXT_OBJECT);
xnt("putTraits", TRAITS_OBJECT);
Parameter | Description |
---|---|
CONTEXT_OBJECT | Event context (JS object). |
TRAITS_OBJECT | User data (JS object). |
Implementing the script
Implement the following script on the landing page:
- html
<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>