Ontraport Enhanced Ecommerce

#Overview

WP Fusion’s Ecommerce Addon (available for Plus and Professional license holders) now supports sending ecommerce transaction data to your Ontraport account for sales made in:

#Global Setup

There are several global settings for Enhanced Ecommerce with Ontraport. These are found within the WP Fusion settings, on the Enhanced Ecommerce tab. The default settings are appropriate for most stores, but you can change them if needed.

#Ontraport Pricing

WP Fusion can send product prices to Ontraport in two different ways:

  • Use product prices as set in Ontraport: With this setting WP Fusion will just send the ID of the product that was purchased, and Ontraport will calculate the order totals based on the product price that’s set in Ontraport. This is useful if you have a multi-currency store or a store in a different currency than Ontraport supports. For example a product that sells for €100 on your site could be configured in Ontraport with a price of $111. When someone purchases the product, $111 would be recorded on the invoice in Ontraport.
  • Use product prices as paid at checkout: This setting sends the product prices as they’re paid at checkout. With this setting a €100 purchase in WooCommerce would be recorded as a $100 purchase in Ontraport. It also works with discounts, so a $100 purchase in WooCommerce with a 20% off coupon would show as $80 in Ontraport.

#Shipping Product

Ontraport doesn’t currently have an API method for tracking shipping charges. To get around this, WP Fusion can create a pseudo-product named “Shipping” which is added to your invoices and includes the shipping amount paid by the customer.

By default WP Fusion will create a new product to record shipping charges automatically during checkout. To disable this feature select Don’t Track Shipping from the dropdown. You can also select a custom product to use to record shipping charges.

#Taxes

By default WP Fusion excludes taxes from product prices sent over the API. However if you sell your products tax-inclusive (for example in Australia) you can select Include in product prices to send the product prices tax-inclusive.

Or, optionally, you can select a pre-existing tax object in Ontraport to be used for taxes on your products.

Note: If you’ve just created a tax object in Ontraport, click Resynchronize Available Tags and Fields from the Setup tab and reload the page to load the new tax object into the dropdowns.
A WooCommerce purchase synced into Ontraport using WP Fusion, using a tax object with a 10% tax rate

When a tax object is selected, WP Fusion will send your product prices to Ontraport without tax, and Ontraport will then calculate the tax on the order based on the tax rate set on your tax object.

As an example, let’s imagine that we’re selling a Hoodie for $5, and there’s a 10% tax configured in WooCommerce. For each of the options in WP Fusion, the data would show in Ontraport as:

Don’t sync taxes:
Hoodie: $5
Tax: $0 ($0.50 tax is ignored)

Include in product prices:
Hoodie: $5.50 ($5 + $0.50 tax)
Tax: $0

Existing Ontraport tax object set to 10%:
Hoodie: $5
Tax: $0.50 (calculated by Ontraport)

#Sync Attributes

Some WooCommerce extensions (like WooCommerce Product Addons) collect additional information from the customer for certain products. For example a ring could have a custom engraving, or a shirt might have a size and a color.

Enabling Sync Attributes will add selected attributes as separate line items to the invoice in Ontraport. It’s recommended to leave this disabled unless you need to see that data in Ontraport.

#Product Setup

After you install the Ecommerce Addon (or update to the latest version), WP Fusion will load a list of all configured products in your Ontraport account.

When you go to configure a product in one of our supported ecommerce plugins, you’ll see a new dropdown field where you can link a product on your store with a product already in your Ontraport account.

If you don’t already have the products created in Ontraport, don’t worry… WP Fusion will automatically create them for you at the time of checkout, based on the existing details. WP Fusion will intelligently detect variable products in WooCommerce and create additional Ontraport products based on those variations.

#How it Works

When a customer checks out on your site, WP Fusion will create a new transaction in Ontraport with the products purchased, the quantities, and total sale value. This sale data will be tied to the contact record who made the purchase.

#How it Looks

Products dynamically added to the Ontraport products list, including variable products.
Purchases will be tracked in Ontraport’s purchase logs and can be used in all reports.
You can also view a customer’s purchase history from the Purchases tab within their contact record.

#Video – Enhanced Ecommerce – Ontraport

#Refunds

If you refund an order in WooCommerce, or change an order’s status to Refunded, the transaction will automatically be updated in Ontraport.


#Affiliates / referral partners

WP Fusion will automatically detect Ontraport partner tracking cookies and will associate them with new orders sent over the API.

This will work as long as the oprid cookie is set, which requires Ontraport site tracking to be enabled on your site.

When a referral is recorded for an order it will be logged in the WP Fusion logs with a message, “Recording referral for partner ID”.

#Modifying the API data

WP Fusion supports using filters to modify the data sent to Ontraport with an ecommerce order. The filter is wpf_ecommerce_ontraport_add_transaction.

#Custom affiliate logic

As an example, in this snippet we limit affiliate commissions based on the products in the order.

/**
 * Conditionally set the affiliate ID for a transaction.
 *
 * @link https://api.ontraport.com/doc/#the-order-object
 *
 * @param array $order_data The order data.
 * @param int   $order_id   The order ID in WordPress.
 * @return array The order data.
 */
function conditionally_set_affiliate( $order_data, $order_id ) {

	/* $order_data is structured like:

		$order_data = array(
			'objectID'          => 0,
			'contact_id'        => 123,
			'chargeNow'         => 'chargeLog',
			'trans_date'        => 1686818840000,
			'invoice_template'  => 0,
			'delay'             => 0,
			'external_order_id' => 1234, // order ID in WP.
			'oprid'             => 5, // affiliate ID.
			'offer'             => array(
				'products' => array(
					array(
						'name'     => 'Product name',
						'id'       => 123,
						'quantity' => 1,
						'sku'      => 'SKU',
					),
				),
			),
		);
	*/

	// If the order contains a product named "Widget", disable affiliate referrals.

	if ( isset( $order_data['oprid'] ) ) {

		// An affiliate is set.

		foreach ( $order_data['offer']['products'] as $product ) {

			if ( 'Widget' === $product['name'] ) {
				unset( $order_data['oprid'] );
			}
		}
	}

	return $order_data;

}

add_filter( 'wpf_ecommerce_ontraport_add_transaction', 'conditionally_set_affiliate', 10, 2 );

In this case, if the order has an affiliate ID set, and it contains a product called “Widget”, then the affiliate ID is removed from the order data and no referral will be awarded.

Was this helpful?