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 it to 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() - $order->get_total_tax() - $order->get_total_shipping();
    $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).',
email: "'.$order->billing_email.'",
        });
        </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:

Please note that the placement of the PHP code in your file manager depends greatly on how your Thank You Page is set up in WooCommerce. In order to add this PHP to the correct file, please study the options below carefully:

If you are using the default WooCommerce Thank You Page, open up your file manager, go to the Templates folder and find a file called "thankyou.php". Place the conversion code inside the file like below.

If you are using a theme on your Thank You Page, the theme would overwrite your templates. In this case, this conversion code should be placed in the theme's "functions.php" file. Note: There could be several themes saved in your file manager directory. Place the code in the theme that is applied to the Thank You Page.

After adding the conversion, please make a test conversion using an Advertiser Test Tracking Link from Everflow.

_____________________________________________________________

NEED HELP? OUR CUSTOMER SUCCESS TEAM IS HERE FOR YOU!

We've assembled a superstar team of industry veterans that are available around the clock to make sure that your issues are resolved and questions are answered. You can reach out any time in-platform via Chat or by emailing support@everflow.io.

Did this answer your question?