Order Tracking via API (Server Side)

Set up secure, reliable, and flexible order tracking by connecting directly to our server side API. This method ensures complete data accuracy, enables real-time updates and supports advanced referral functionality.


Average Integration Time: 1 - 3 hours

🛍️ Included in our Shopify App

Why Choose API Integration?
Authentication
Creating and Updating Orders
Order Parameters
Examples

When manually integrating with our platform, you have two options: using the script or integrating Server side via our API.

While the order script/pixel offers a faster setup, we strongly recommend using server side for a more secure, flexible, and reliable solution.

Why Choose Server Side Integration?

Using our server side API provides significant advantages over the script/pixel approach:

  • Robust: Unlike client-side scripts, server-side API calls cannot be blocked or fail to load, ensuring that no order data is lost.

  • Flexible: The API can be integrated with greater versatility across different systems, making it suitable for a wide range of eCommerce setups.

  • Secure: The order confirmation script could theoretically be discovered and manipulated by a user. API communication happens server-to-server, making it much more secure.

  • Updatable: The API allows you to send order updates, such as when an order is partially refunded or cancelled, keeping your data accurate and current.

Authentication

All API requests require basic authentication. You can create API user credentials in the dashboard under Settings > API Users (https://app.duel.me/app/settings/open-api)

If you do not have an operator login for the duel dashboard please reach out to your Brand Success Manager

Creating and Updating Orders

Orders are created and updated via our Open API: https://developers.duel.tech/open-api/ 

  • To create orders, POST to the endpoint https://api.duel.me/v1/orders
  • To update orders, POST to the endpoint https://api.duel.me/v1/orders/{order_id}, with the same parameters and the updated amount for the total parameter
    • The email and promo parameters are not strictly necessary for updates as they have already been captured in order creation
    • A total of 0 will cancel the order

For full order parameter documentation refer to our Open API microsite: https://developers.duel.tech/open-api/

Required Order Parameters

  • order - Order ID
  • total - The final order amount, which can be net if the brand chooses to exclude taxes shipping etc
  • currency - Order currency
  • email - Email of customer placing order
  • promo - Promo code used in the order (if multiple promos are used in an order, they should be sent in an array)
  • affiliate - Mark order as coming via an affiliate link by passing the member’s username / affiliate parameter.

Recommended Parameters

  • date - using the ISO 8601 format. If no date is provided, the current date at the time of the request will be used.
  • customer_id - ID of customer placing order, used to track life time value
  • new_customer - If customer placing order is a new customer pass a value of y or true (boolean)
  • total_gross - The order amount before any deductions, including discounts, shipping, and other fees

Optional Parameters

  • instore - Mark order as in-store by passing a value of y or true (boolean) 
  • points -  can be sent when you want to allocate additional points for a specific order (i.e. when an order is placed by a new customer)
  • commission -  can be sent when you want to allocate specific commission for an order (i.e. when an order is placed by a new customer)
  • commission_currency - should be sent along with the commission figure above

Examples 

Below are example implementations. If your backend uses a different language, or if there are any problems, please contact us.

.NET

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;

static readonly HttpClient client = new HttpClient();

static async Task Main(string[] args)
{
    var values = new Dictionary<string, string>
    {
        // ... Order parameters
    };

    try
    {
        client.BaseAddress = new Uri("https://api.duel.me/");

                var response = client.PostAsync("v1/orders", new StringContent(
                values.ToString(),
                Encoding.UTF8,
                "application/json"));

        var jsonString = await response.Content.ReadAsStringAsync();
    }
    catch (Exception e)
    {
        // Handle exception
    }
}

Node.js

const https = require('https');

const data = JSON.stringify({
  // ... Order parameters
});

const options = {
  hostname: 'api.duel.me',
  path: '/v1/orders',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': Buffer.byteLength(data)
  }
};

const req = https.request(options, (res) => {
  let data = '';

  res.on('data', (chunk) => {
    data += chunk;
  });

  res.on('end', () => {
    const { status, result } = JSON.parse(data);
    // use reponse data for further processing
  });
}).on('error', (err) => {
  // handle error
});

req.write(data);
req.end();

PHP

<?php

$body = json_encode(array(
  // ... Order parameters
));

$curl = curl_init('https://api.duel.me/v1/orders');

curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));

$result = curl_exec($curl);

?>