Order tracking

Here you will find integration instructions for orders tracking. Order tracking allows us to understand whether your customers actually add to cart and checkout (order) the size we recommended.

NOTE that no sensitive customer data is accessed by Easysize nor is any sensitive data transmitted.



Add to cart

Whenever an item is added to cart, it should be saved in the cookies as an object with the following structure:

  "product_id": "<easysize_pageview_id>"


Here is how the cookie might look like, if the user added three items to cart:

  "123": 777321,
  "213": 777322,
  "321": 777323


Once a purchase is made (was paid for), you should be able to access all the items that were bought. Save them to a variable (order in given example).

Also retrieve the cookie of the add to cart object you implemented before (items_added_to_cart in given example).

items_added_to_cart_keys = items_added_to_cart.keys(); // [123, 213, 321]
orders = order.items; // [<Product>,..]
order_id = order.id; // 9999

for(var i = 0; i < orders.length; i++) {
    for(var y = 0; y < items_added_to_cart_keys.length; y++) {
        if(orders[i].product_id == items_added_to_cart_keys[y]) {
             // If we get here, the item that was added to cart was actually purchased

             // We need to send a GET request to Easysize servers telling that, with the size of the item that was purchased.
             // Look below for explanation of the request query parameters

             size = orders[i].item_size;
             pageview = items_added_to_cart[items_added_to_cart_keys[y]];

             // example request url
             // https://popup.easysize.me/api/123456789/tracking/order?purchased_size=S&pageview_id=e765386f-f5b6-444e-818b-ff7ce7541195&order_id=412496&product_id=1&user_id=2

In the given example we have two loops and compare whether the item that was added to cart was actually bought. If it was, we then send tracking information to Easysize servers.

Request breakdown

[GET] https://popup.easysize.me/api/<shop_id>/tracking/order


timestamp takes precedence over created_at, you do not need to provide both, pick the one which is easier to retrieve in your system

PHP Example

NOTE If you copy the code, do not forget to update the variables to fit to your system.

Add to cart

if($_COOKIE['espageview']) {
    if($_COOKIE['es_cart_items']) {
        $items_in_cart = json_decode($_COOKIE['es_cart_items']);
    } else {
        $items_in_cart = new stdClass();

    $items_in_cart->$product['id'] = $_COOKIE['espageview']; // $product['id'] might look different in your system
    setcookie('es_cart_items', json_encode($items_in_cart), time() + 60 * 60 * 24 * 7, "/");


// Get all products in order. Note that these variables might look different in your system!
$products_in_order = $_SESSION['order'];
$order_id = $_SESSION['order_id'];
$user_id = $_SESSION['user_id'];

if($_COOKIE['es_cart_items']) {
    $items_added_to_cart = json_decode($_COOKIE['es_cart_items']);
    foreach ($products_in_order as $product) {
        if($product['id'] && isset($items_added_to_cart->$product['id'])) {
            $data = http_build_query(
              // $product['size']['name'] is the purchased item size. It might look different in your system!
              'purchased_size' => $product['size']['name'],
              'pageview_id' => $items_added_to_cart->$product['id'],
              'order_id' => $order_id,
              'product_id' => $product['id'],
              'price' => $product['price'],
              'price_currency' => 'eur',
              'user_id' => $user_id,
              'timestamp' => $order['timestamp'] // value might look something like '1514125932'

            // Note that shop id must be your unique shop id provided by Easysize. In this case DemoOrder12
            $curl = curl_init("https://popup.easysize.me/api/DemoOrder12/tracking/order?{data}");
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

    // Do not forget to remove the cookie
    setcookie('es_cart_items', '', time() - 3600, '/');

Remember, if you encounter a problem, reach out to us at info@easysize.me, our team is always ready to help you out!