Displaying Comprehensive Attribution Data in WooCommerce Orders

In a recent Business Bloomer Club discussion, a useful code snippet was shared to enhance the WooCommerce order overview table by displaying all available attribution data for each order.

Out of the box, WooCommerce typically shows only the “origin” of a customer’s order, which is a basic detail that lacks critical context for analyzing campaign performance. This snippet goes a step further by pulling in additional details, including the source, medium, and campaign associated with each order.

For WooCommerce merchants and marketing professionals, having this level of insight right in the order overview page can provide a clearer understanding of which campaigns drive sales, how customers are navigating to the store, and overall campaign effectiveness.

Why Detailed Attribution Data Matters

Knowing only the “origin” is limiting, as it doesn’t tell the full story of how users arrived at the store. By accessing additional attribution data, you gain a fuller picture of user journeys. With more detailed attribution—such as source, medium, and campaign—merchants can more accurately assess the effectiveness of each marketing channel and make data-driven decisions.

Code Snippet to Display All Attribute Channels

Below is a PHP snippet to include all attribute channel information in the order overview table. With this code, you can show “source,” “medium,” “campaign,” and “origin” directly on the order page, giving you instant access to valuable data.

// Add new columns to the order table
add_filter('manage_edit-shop_order_columns', 'add_custom_order_column', 20);
function add_custom_order_column($columns) {
    $columns['utm_source'] = __('Campaign', 'woocommerce');
    return $columns;
}

// Populate the new columns with UTM data
add_action('manage_shop_order_posts_custom_column', 'display_custom_order_column', 20, 2);
function display_custom_order_column($column, $post_id) {
    if ($column === 'utm_source') {
         echo get_post_meta($post_id, '_wc_order_attribution_utm_source', true);
		 echo '<br/>';
		 echo get_post_meta($post_id, '_wc_order_attribution_utm_medium', true);
		 echo '<br/>';
		 echo get_post_meta($post_id, '_wc_order_attribution_utm_campaign', true);
    }
}

Implementing the Snippet

To use this code, simply add it to your theme’s functions.php file. Once implemented, it will enhance the order details page in the WooCommerce admin area by adding new lines for each attribution parameter—source, medium, campaign, and origin.

Conclusion

For any WooCommerce store owner looking to gain deeper insights into the effectiveness of their marketing campaigns, this code snippet offers a simple, powerful solution.

By displaying full attribution details within each order overview, merchants can make informed decisions to optimize their campaigns and increase conversion rates. This example highlights the flexibility of WooCommerce and the power of small customizations to enhance store performance and customer insights.

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

Reply

Your email address will not be published. Required fields are marked *