IMPORTANT *It is not recommended that you try to complete this setup without instruction from the Everflow team or from your dev team. Failure to place the code directly could result in your whole website going down. *

Step #1

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 Footer.

You can get to the Footer section inside the Header and Footer plugin by going to Settings > Header and Footer Scripts in your Wordpress account:

Step #2

Conversion Script

Prepare your conversion script. Please copy this into a note pad and then replace the correct values.

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="INSERT_YOUR_TRACKING_DOMAIN/scripts/sdk/everflow.js"></script>

    <script type="text/javascript">
    EF.conversion({
        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;
    }

_________________________________________________________________

Please replace INSERT_ADVERTISER_ID with the advertiser ID, this can be found under Offers > Manage > Click the Offer Page Here:

In this case you would use 139 in that spot.

Please replace INSERT_YOUR_TRACKING_DOMAIN with the tracking domain found under Offers > Manage > Click the Offer in the JavaScript SDK section here:

In this case you would use: https://www.serve-eflow-test.com

Please note that your domain will be different.

Step #3

After you have completed Step #2 please create your functions.php url (so you can edit the page).

First copy your store domain:

In this example mine is https://www.ef-wp-test.com/

Then you will navigate to Appearance > Themes to find what theme you are using:

In this example I am using "Storefront"

Please convert this value to all lower case letters, in this case it would be "storefront"

Then insert those values into this url:

DOMAINwp-admin/theme-editor.php?file=functions.php&theme=THEME

In this example my domain will be:

https://www.ef-wp-test.com/wp-admin/theme-editor.php?file=functions.php&theme=storefront

Once you successfully navigate to that url please scroll all the way down to the bottom of the page and input the code, like this:

Then hit "Update File" at the bottom of the screen:

Step #4

Please then generate a test link from Everflow and test to see if a sale tracks back to our system. If you need assistance please reach out to Everflow support

_____________________________________________________________

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?