WooCommerce Tracking

WooCommerce is an e-commerce platform built on WordPress.  It is aimed for small to large-sized online shops that use WordPress.

Integrating ‘Woocommerce Tracking’ in your Tracknow Campaign

  1. In order to set your Tracknow affiliate network for your WooCommerce shop, first, navigate to the ‘Campaigns‘ section > ‘Add a CampaignorEdit‘ (for an existing campaign):

  1. After selecting the campaign you wish to add to your WooCommerce store, select the ‘Tracking‘ tab > scroll to the bottom of the page > click in the ‘Image‘ section, and copy the code.

  1. WooCommerce does not allow us to input tracking pixels through interface settings, therefore we must manually update the code.
  • Please make the following modifications to the file:

The name of the file will look like this if you have a customized theme:

  • Locate the following line:
<?php do_action( 'woocommerce_thankyou', $order->id ); ?> 

To send the order values to Tracknow, add the copied pixel below this line and change the parameters:

  • for CPA goal (pass Order ID):
<img src="https://yourcompany-tracking.tracknow.info/success.jpg?campaign_id=XXX&goal=your_goal&order_id=<?php echo $order->id; ?>" height="1" width="1" />
  • for CPS goal (pass Order Amount and Order ID):
$order_id = $order->get_id(); // Get the order ID
$order_total = $order->get_total(); // Get the order total
$order_shipping = $order->get_shipping_total(); // Get the shipping total
$coupons = $order->get_used_coupons(); // Get the array of used coupon codes
$coupon_code = !empty($coupons) ? $coupons[0] : ''; // Get the first coupon code if available

$tracking_url = "https://yourcompany-tracking.tracknow.info/success.jpg?campaign_id=XXX";
$tracking_url .= "&order_id=$order_id";
$tracking_url .= "&amount=" . ($order_total - $order_shipping);
$tracking_url .= "&coupon=" . urlencode($coupon_code);
$tracking_url .= "&goal="; //The goal may be empty

<img src="<?php echo $tracking_url; ?>" height="1" width="1" />

Please ensure that you adjust the URL and change the XXX to your campaign_id. Default campaign_id=1

If you have any issues setting up the WooCommerce Tracking, please contact the ‘Tracknow’ Support Team by clicking ‘here‘, we will do our best to answer all of your inquiries.

Related Articles