WooCommerce Sync Settings

WooCommerce: Source Tracking

Metorik will try to use WooCommerce's built-in order attribute feature (2024+) to get an order's source information.

We will also attempt to track the source through the Metorik Helper plugin if the source from WooCommerce is unavailable, but we can only track this ourselves from the moment you install the Metorik Helper plugin. You can disable this by following the steps below.

The data it tracks is used in the order sources report, customer sources report, and also available to you in the order filters and exports.


Metorik Helper source tracking

When a visitor comes on your site for the first time, Metorik receives and stores data about a source and uses it to attribute orders made by the customer. This source tracking cookie lasts in your customer's browser for 6 months, and can be modified with the metorik_cookie_lifetime     filter (see Metorik Helper V2 for additional documentation on available filters).

For more information on UTM parameters, check out this  beginner's guide and Buffer's complete guide.

Note: Behind the scenes, Metorik currently uses sourcebuster.js. For technical details, check out the documentation, and feel free to ask us questions about it.

Order sources

The source is set on an order during the checkout.

Customer sources

The customer source is set using the source of their first order (set during checkout). If they have not yet ordered/only registered, then no source is logged.


How Metorik chooses the UTM source for reporting and filters

When you filter or segment by UTM Source, Metorik uses a priority order to decide which value to show.

  1. Metorik first checks the WooCommerce order attribution fields (for example, _wc_order_attribution_utrm_source).

  2. If the WooCommerce field is missing or empty, Metorik falls back to its own helper-plugin fields (for example, _metorik_utm_source).

This means an order can have two different source values stored in the background, but only one will appear as the official UTM Source in reports and filters. The WooCommerce value always takes priority.

General example

Imagine an order where WooCommerce stores the following:

  • _wc_order_attribution_utrm_source = email-1

  • _metorik_utm_source = google-cpc

Because the WooCommerce field exists and is not empty, the order’s UTM Source will be reported as email-1. If the WooCommerce field had been empty, Metorik would have used google-cpc instead.

If you need to see both values for an order, you can include the custom meta fields in an export or view them directly on the order page.

Why segments can look different

If your saved segment or filter uses the UTM Source field, it will match the same priority rule above. If an order has a value in the WooCommerce field that you did not expect, it may still appear in the segment because the WooCommerce field is the one being checked first.

To verify which source field is driving a specific order’s UTM value, compare the two stored keys in the order metadata.


My order or customers sources report is empty

Keep in mind: Metorik is only able to track the source from when you started using Metorik.

But if it's been a few days and your sources report is still empty, Metorik is likely unable to record the source in the order data.

Normally this is due to a custom checkout or checkout changes. To fix this, make sure your custom checkout page has the following code somewhere:

<?php do_action( 'woocommerce_after_order_notes', $checkout ); ?>

This should be there by default but if you've removed it, Metorik will have trouble storing the source data.

For custom customer registration forms, you may need to ensure it has this code in the form just before the register button:

<?php do_action( 'woocommerce_register_form' ); ?>

Let us know if you need a hand fixing this up.


Where data is stored

Metorik stores the source data under custom fields/meta for each customer and order. We use a few different keys, including:

  • _metorik_utm_source

  • _metorik_utm_campaign

  • _metorik_utm_medium

And some others for different UTMs and Engage/cart data.


It's possible to change the time we remember cookies for and how long sessions last, by adding some custom code to your site through the functions.php file or a plugin like  Functionality. Cookies are in months and sessions are in minutes.

Change how long cookies are remembered (in months):

add_filter( 'metorik_cookie_lifetime', 'mtk_custom_cookie_time' );
function mtk_custom_cookie_time() {
    return 12; // 12 months
}

Change how long sessions last (in minutes):

add_filter( 'metorik_session_length', 'mtk_custom_session_time' );
function mtk_custom_session_time() {
    return 60; // 60 minutes
}

Removing Metorik's source tracking feature

If you'd prefer Metorik didn't track customer session activity and sources, you have a couple options, where you can add some PHP code using a Code Snippets plugin or to your functions.php.

Firstly, you could use this code to stop Metorik storing the source tracking data on the backend when an order/customer is made:

add_filter('metorik_source_tracking_enabled', '__return_false');

This is a good option as it keeps the Metorik Javascript running for tracking carts.

Alternatively, if you'd prefer to not track sources or carts at all, you can disable the Metorik Javascript completely, using code like this:

add_action( 'wp_print_scripts', 'mtk_helper_dequeue_scripts' );
function mtk_helper_dequeue_scripts() {
    wp_dequeue_script('metorik-js');
}

If you wanted to disable it just for logged in users, you could use this code instead:

add_action( 'wp_print_scripts', 'mtk_helper_dequeue_scripts' );
function mtk_helper_dequeue_scripts() {
    if (is_user_logged_in()) {
        wp_dequeue_script('metorik-js');
    }
}

Was this helpful?