Click Script

For the click setup please add the header and footer plugin found here

In the Everflow JS SDK section on the offer page copy the Click code and paste it into the header.

Conversion Script

*IMPORTANT* - Below is base script, immediately followed by the changes needed to apply to it before you add to your thankyou.php file in your WooCommerce file manager, to add file manager to your wordpress / WooCommerce pages please go here

<?php add_action( 'woocommerce_thankyou', 'my_custom_tracking' );

function my_custom_tracking( $order_id ) {
// Lets grab the order
    $order = wc_get_order( $order_id );

    //Everflow order objects
    $efOrder = array();
    $efOrder['items'] = array();
    $efOrder['oid'] = $order_id;
    $efOrder['amt'] = $order->get_total();
    $efOrder['bs'] = $order->get_billing_state();
    $efOrder['bc'] = $order->get_billing_country();

    // Determine if any coupons were used for this transaction
    $coupons = "";
    $couponCount = 0;
    foreach ($order->get_used_coupons() as $coupon) {
        $couponCount++;
        if($couponCount > 1) { // do not add comma unless more than one coupon
            $coupons .= ',';
        }
        $coupons .= $coupon;
    }
    $efOrder['cc'] = $coupons;

    // This is how to grab line items from the order
    $line_items = $order->get_items();

    // This loops over line items
    $efItems = array();
    foreach ( $line_items as $item ) {
        //Init Everflow item
        $efItem = array();
        // This will be a product
        $product = $order->get_product_from_item( $item );
        // This is the products SKU (variant or parent)
        $efItem['vs'] = '';
        $efItem['ps'] = '';
        if ( $product->get_type() === 'variation' )
            { $efItem['vs'] = $product->get_sku(); }
        else
            { $efItem['ps'] = $product->get_sku(); }
        // This is the qty purchased
        $efItem['qty'] = $item['qty'];
        // Line item total cost including taxes and rounded
        $efItem['p'] = $order->get_line_total( $item, true, true );
        // Add this to Everflow items
        $efItems[] = $efItem;
    }
    $efOrder['items'] = $efItems;

    $javascriptCode = '
    <script type="text/javascript"
    src="https://INSERT_TRACKING_DOMAIN/scripts/sdk/everflow.js"></script>

    <script type="text/javascript">
    EF.conversion({
        offer_id: 'INSERT_OFFER_ID', // OR you can use aid: 'INSERT_ADVERTISER_ID',
        amount: '.$order->get_total().',
        adv1: "", //Optional
        adv2: "", //Optional
        adv3: "", //Optional
        adv4: "", //Optional
        adv5: "", //Optional
        order: '.json_encode($efOrder).',
        });
        </script>';
        echo $javascriptCode;
    }
?>

_________________________________________________________________

The offer_id INSERT_ value can be found under Offers > Manage > Click the Offer Page Here:

Please replace INSERT_YOUR_TRACKING_DOMAIN with the tracking domain found under Offers > Manage > Click the Offer and conversion method section here:

__________________________________________________________________

Adding the PHP to the correct file in your WooCommerce file manager:

In order to add this PHP to the correct file, please open up your file manager and find a file called "thankyou.php". 

Here is how the directory should look:

Then place that PHP inside the if statement that will load when a valid order is completed.

Did this answer your question?