Order Tracking & Attribution (Server Side)

This allows Duel to track all the relevant order information on an eCommerce site. It allows the enabling of loyalty & advanced referral functionality as well as order updates.


Average Integration Time: 1 - 2 hours

🛍️ Included in our Shopify App

Although the order confirmation pixel is easier to integrate, We'd always recommend the server side solution for more accurate order data. 

You will still need to integrate the pixel in addition to server side tracking as while the server side covers all orders, it dose not track affiliate links.

Server Side Benefits:

  • Robust: The server side solution will never 'lose' any information (script's can be blocked or fail to load).
  • Flexible: It can be integrated with more versatility than the order confirmation pixel.
  • Secure: The order confirmation script could theoretically be discovered by a user and manipulated.
  • Updatable: It is also possible to send order updates when the order was (partly) refunded or cancelled.

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

Order Parameters

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

  • order - Order ID
  • total - Order total
  • total_gross - Order total before any promotional discounts are applied
  • 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)
  • 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)

Additional Parameters

  • instore - Mark order as in-store by passing a value of y or true (boolean) 
  • affiliate - Mark order as coming via an affiliate link by passing the member’s username / affiliate parameter
  • points -  can be sent when you want to allocate specific points for an 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);

?>