This page explains the process of implementing the server-to-server tracking for Retrack.
Sign in to the portal
Click here to access your account.
Find your API token
Each user is given a unique API token. To find it, sign in to the portal and click your avatar in the top right corner and select "Profile". Your API token is displayed there and can be copied with one click.
Create a redirect page
Whether a redirect page is required depends on how your program is configured in Retrack. Each program has a Uses Redirect Page setting that can be toggled on or off. Check this setting on your program before proceeding.
When enabled, Retrack sends the user to your redirect page first. The redirect page saves the click identifier in a cookie and then forwards the user to the actual destination. Without this step, the tracking script on your confirmation page has no way of linking a lead or purchase back to the original click.
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. Save the click identifier in a cookie named retrack_click with a 10-day expiration. Once stored, redirect the user to the deeplink URL.
document.cookie = `retrack_click=${click};expires=${expires};path=/;secure;samesite=lax`;
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
https://retrack.refunder.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:
| Field | Value | Explanation |
|---|---|---|
| Total price | 125 SEK | |
| VAT | 25 SEK | |
orderSum |
10000 | (125 - 25) × 100 |
vatSum |
2500 | 25 × 100 |
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.
Updating transactions
You can update a transaction by sending a POST request to the following endpoint. The endpoint accepts the same input as the creation endpoint, but you must pass the uuid of the transaction you want to update in the URL.
https://retrack.refunder.com/api/v2/transactions/:uuid
Rejecting transactions
You can use the update endpoint to reject a transaction by passing the status field with the value rejected. Example:
{
"status": "rejected"
}
It's not possible to update a transaction's status once it has been approved.
For more details on updating transactions, see the full update transaction guide.
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.