# Sending data (server)

Each request(trace) can be sent either through the browser or server side. In order to re-identify customers after they leave their email address (login, register, sign up for newsletter etc). edrone adds unique identifiers stored inside cookies(first-party&third-party) or localStorage to each request. Even after customers are logged out from the store, edrone is able to re-identifiy them. This is the main reason why the browser is a default option.

In cases when the store has access to customer email, those additional identifieres are not needed anymore.

You will find cases (based on action_type) where store can send request via server below:

Subscription Change
The "subscribe" event allows to change customer subscription status. It's important to change field "sender_type" to server. Subscription change won't work without that.


<?php
  function subscriptionChange(){
    $edroneData = 'version=' . '1.0.0' .
       '&app_id=' . 'YOUR APP ID' .
       '&email=' . 'email@example.pl' .
       'subscriber_status=' . '0/1' .
       '&action_type=' . 'subscribe' .
       '&sender_type=' . 'server';
       return $edroneData;
    }

  function httpPost($url, $params) {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_POST, count($params));
     curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
     $output = curl_exec($ch);
     curl_close($ch);
     return $output;
  }
  httpPost('https://api.edrone.me/trace', subscriptionChange());


Order cancel
The "order_cancel" event allows marking orders in edrone CRM system as deleted.


<?php
  function orderCancel(){
    $edroneData = 'version=' . '1.0.0' .
       '&app_id=' . 'YOUR APP ID' .
       '&email=' . 'email@example.pl' .
       '&order_id=' . '00001' .
       '&action_type=' . 'order_cancel' .
       '&sender_type=' . 'server';
       return $edroneData;
    }

  function httpPost($url, $params) {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_POST, count($params));
     curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
     $output = curl_exec($ch);
     curl_close($ch);
     return $output;
  }
  httpPost('https://api.edrone.me/trace', orderCancel());


Order


<?php
  function order(){
    $$edroneData = 'version=' . '1.0.0' .
        '&app_id=' . 'YOUR_APP_ID' .
        '&email=' . $order->email .
        '&first_name=' . $order->first_name .
        '&last_name=' . $order->last_name .
        '&product_ids=' . join('|', $product_ids) .
        '&product_titles=' . join('|', $product_titles) .
        '&product_images=' . join('|', $product_images) .
        '&product_urls=' . join('|', $product_urls) .
        '&product_counts=' . join('|', $product_counts) .
        '&product_category_ids=' . join('|', $product_category_ids) .
        '&product_category_names=' . join('|', $product_category_names) .
        '&order_id=' . $order->order_id .
        '&order_payment_value=' . $order->order_payment_value .
        '&base_payment_value=' . $order->order_payment_value .
        '&sender_type=' . 'server' .
        '&base_currency=' . $order->order_currency .
        '&order_currency=' . $order->order_currency .
        '&action_type=' . 'order' .
        '&country=' . $order->country .
        '&city=' . $order->city .
        '&phone=' . $order->phone .
        '&customer_tags=' . join('|', $order->customer_tags) .
        '&subscriber_status=' . '' .
        '&event_utc_date=' . $order->event_date .
        '&utc_time=' . utcNow();
    return $edroneData;
    }

  function httpPost($url, $params) {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_POST, count($params));
     curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
     $output = curl_exec($ch);
     curl_close($ch);
     return $output;
  }
  httpPost('https://api.edrone.me/trace', order());