How to
Implement Server-to-Server Tracking for Transactions
This page explains the process of implementing the server-to-server tracking for Retrack.
Sign in to the platform
Click here to access your account.
Find your API token
Each user is given an API token which you can find once signed in to the platform. Click on your name on the top right part of the screen and then select "Profile" from the dropdown menu. You should be presented with this view where your API token is displayed:
Create a redirect page
You will receive traffic from Retrack with the following two URL parameters: click and deeplink. Here is one example:
https://www.store-domain.com/retrack?click=625fae10-1eb0-11eb-adc1-0242ac120002&deeplink=https%3A%2F%2Fwww.store-domain.com%2Fsome-product
Create a new page that can accept these two parameters. The click identifier should be saved for later use and must persist for 10 days. You can choose to save it in a coookie, in the session, or any other way that makes it persistant. Once the click identifier is stored the user should be redirected to the deeplink URL.
The redirect URL can be any URL on your main store domain. Just make sure to communicate the exact URL of this page to Retrack.
Send orders to Retrack
Whenever an order is completed, you should check if it's affiliated with Retrack based on the cookie you set initially. All connected orders should be uploaded to Retrack using our API as soon as possible.
API Endpoint
POST https://retrack-app.com/api/v2/transactions
Authenticate by passing your API token with the Authorization header. For example:
Authorization: Bearer DbV6KYhMm7firiNtgfOCEmRohglfAQUTUy4FudGOKtetC0yYSaKtOXIedfNX
Example input:
{
"event": "1f80e399-6f55-4cef-b8b0-0f74752c1ceb",
"click": "59d08c54-18e6-4e0d-9c06-d18be3510e43",
"orderNumber": "test1234",
"orderSum": 10100,
"vatSum": 2000,
"currency": "SEK",
"products": [
{
"event": "1f80e399-6f55-4cef-b8b0-0f74752c1ceb",
"reference": "testabc123",
"quantity": 1,
"name": "Testprodukt",
"price": 10100,
"vat": 2000
}
]
}
If the order has a general discount you can pass it as a separate field: discountSum. This field will mainly be used when validating the transaction sum agains the sum of all products, which will otherwise not match.
Note that the order sum should be represented without VAT and exclude shipping. All monetary values should be sent in minor units. For example:
Total price: | 125 SEK |
VAT: | 25 SEK |
Price - VAT in minors: | 10000 |
VAT in minors: | 2500 |
A note about orders with mixed events - The main transaction object can only have one unique event, but it's possible to override the event on product level. Just replace the event property with the actual event for this product. Retrack will automatically calculate the correct commission based on each event. The responsibility to keep track of which event to display falls on the store.
Example response:
{
"data": {
"uuid": "3afc4a82-93c3-423f-8ee8-542ccb315931",
"order_number": "test1234",
"order_sum": 200000,
"vat_sum": 40000,
"commission": 4000,
"currency": "SEK",
"vouchers": [],
"created_at": "2020-11-04 11:09:31",
"click": {
"uuid": "59d08c54-18e6-4e0d-9c06-d18be3510e43",
"ref": "38315327",
"ref2": null,
"ref3": null,
"deeplink": null,
"ip_address": "80.216.223.143",
"browser": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36",
"referer": "https://www.refunder.se/",
"country": "SE",
"created_at": "2020-10-08 08:13:43"
},
"publisher": {
"uuid": "e5adcbc6-31a8-4e1b-8351-835dddc16921",
"name": "Refunder SE",
"created_at": "2020-05-19 15:44:36"
},
"advertiser": {
"uuid": "4062146a-9078-4e9a-8a88-2b9066c562d2",
"name": "Store Name SE",
"created_at": "2020-05-19 15:46:02"
},
"program": {
"uuid": "7649bf56-4345-46e4-8c77-04bbd2f3bcd3",
"title": "Store Name SE",
"created_at": "2020-05-19 15:47:02"
},
"event": {
"uuid": "1f80e399-6f55-4cef-b8b0-0f74752c1ceb",
"title": "Sale Whole Store",
"commission": "20.00",
"created_at": "2020-05-19 15:48:46"
},
"status": {
"name": "pending",
"reason": null,
"created_at": "2020-11-04 11:09:31"
},
"products": [
{
"reference": "testabc123",
"name": "Testprodukt",
"price": 200000,
"vat": 40000,
"created_at": "2020-11-04 11:09:31"
}
]
}
}
The API will return with HTTP 200 OK if the transaction has been successfully saved. For all other responses you can retry as many times as you need.
Done
That's it! You have now implemented tracking for Retrack. We would now like to test the implementation before it goes live. Reach out to us with testing instructions.