As part of our support for eCommerce and product data in CAKE, we also expanded the functionality of our commerce pixel. On ecommerce (Storefront based) offers, you can now implement the CAKE Commerce Pixel (conversion pixel) to pass order detail information when an order is generated.
The updated pixel format looks like the following:
Sample Commerce Conversion Pixel
<iframe src="http://trk.clientdomain.com/p.ashx?o=769&t=123&r=25566&ecsk=144^201^242&ecqu=1^2^3&ecpr=10.00^8.00^12.00&ecld=0^1.00&ecst=61.00&ecd=2&ectx=5.80&ecsh=5.00&ect=69.80&ecco=US&ecrg=CA" width="1" height="1" frameborder="0"></iframe>
Sample Postback Request (Server to Server)
https://trk.clientdomain.com/p.ashx?a=1&t=123456&r=25566&ecsk=123ABC^321CMS^987132&ecqu=1^2^3&ecpr=10.00^8.00^12.00&ecv=CA32X7&ecc=FF25^SHOES50OFF&eccu=USD&ecst=62.00&ectx=5.80&ecsh=5.00&ect=72.80&ecco=US&ecrg=CA
Pixel Parameters:
r - request Id - generated by CAKE (append your offer link with #reqid#)
a - Advertiser ID *
t - Order/Transaction ID
ecsk - Line Item SKU
ecqu - Line Item Quantity
ecpr - Line Item Price Per Item
ecld - Line Item Discount
ecv - Voucher
ecc - Coupon
eccu - Order Currency
ecd - Order Discount
ecst - Order Sub Total
ectx - Order Tax
ecsh - Order Shipping
ecco – Shipping Country
ecrg – Shipping Region
ect - Order Total *
p - Revenue
*Denotes Mandatory Fields
If you have multiple line items as part of your order, you can separate them respectively with the “^” symbol. For example, you may have an order that has two line items (two skus). You can post both skus in the ecsk parameter (Sku parameter) as such: exsk=sku1^sku2.
Generating the Commerce Pixel
The commerce pixel is generated by a script that pulls parameters from your ecommerce platform and either drops an iframe pixel on the confirmation page or performs a postback into CAKE.
The following is an example script that creates an iframe conversion pixel from the order object in WooCommerce:
<?php
/* CAKE Ecommerce Pixel Generator for WooCommerce */
// ADVERTISER ID
$aid = '1';
// TRANSACTION ID
$tid = $order->get_order_number();
$tid = str_replace('#', '', $tid);
// LINE ITEMS
$items = $order->get_items();
foreach ( $items as $item ) {
$product_id = $item['product_id'];
$qty = $item['qty'];
$line_subtotal = $item['line_subtotal'];
$line_total = $item['line_total'];
$line_discount = $line_subtotal - $line_total;
$product_id_list[] = $product_id;
$qty_list[] = $qty;
$line_total_list[] = $line_total;
$line_discount_list[] = $line_discount;
}
$line_item_sku = implode('^', $product_id_list);
$line_item_quantity = implode('^', $qty_list);
$line_item_price_per_item = implode('^', $line_total_list);
$line_item_discount = implode('^', $line_discount_list);
// COUPON
$coupon = $order->get_used_coupons();
$coupon = $coupon[0];
// ORDER CURRENCY
$currency = $order->get_order_currency();
// ORDER DISCOUNT
$discount = $order->get_total_discount();
// ORDER TAX
$tax = $order->get_total_tax();
// ORDER SHIPPING
$shipping = $order->get_total_shipping();
// ORDER TOTAL
$total = $order->get_total();
// REVENUE
$revenue = $order->get_total() - ($order->get_total_shipping() + $order->get_total_tax());
// ORDER SUBTOTAL
$subtotal = $revenue + $discount;
// OUTPUT IFRAME CONVERSION PIXEL
echo '<iframe src="http://ngtrk.com/p.ashx?a=' . $aid . '&t=' . $tid . '&ecsk=' . $line_item_sku . '&ecqu=' . $line_item_quantity . '&ecpr=' . $line_item_price_per_item . '&ecld=' . $line_item_discount . '&ecc=' . $coupon . '&eccu=' . $currency . '&ecd=' . $discount . '&ecst=' . $subtotal . '&ectx=' . $tax . '&ecsh=' . $shipping . '&ect=' . $total . '&p=' . $revenue . '" width="1" height="1" frameborder="0"></iframe>';