WooCommerce Integration

Integrating Tracknow to WooCommerce Campaign

  1. In order to set your Tracknow affiliate network for your WooCommerce shop, first, navigate to the ‘Campaigns‘ section > ‘Add a Campaign‘ or ‘Edit‘ (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:
wp-content/plugins/woocommerce/templates/checkout/thankyou.php 

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

themes/{custom_theme_name}/woocommerce/checkout/thankyou.php 
  • Locate the following line and add the CPA/CPS pixel below:


To send the order values to Tracknow, add the pixel below and change the workspace URL:

  • 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):
<?php
$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