WooCommerce: Source Tracking

Through the  Metorik Helper plugin, Metorik tracks where your customers come from and the UTM tags present when they come to your site. 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.

This data is only tracked from the moment you installed the Metorik Helper plugin on your site.

However, if you are using WooCommerce's built-in order attribution feature (2024+), we will try to get the source information from there when Metorik did not track it.


By default, a cookie lasts in your customer's browser for 6 months.

By default, a customer's session is considered 30 minutes.

The session time affects only referral sources overriding. When a visitor comes on your site for the first time, Metorik receives and stores data about a source. After some time, this visitor might return to your website, but from another source, and we need some rules to decide if we should overwrite previous source or not.

The rules Metorik uses are aligned with Google Analytics:

  • UTM and Organic sources always override any previous source.
  • Type-in (direct) never overrides a previous source.
  • Referral source overrides previous source only if there is no user session at the moment. If it’s within the same session (eg. within 30 minutes of first coming to the site) - a referral source will never override previous source.

Explanation to referral logic: sometimes visitor within a current visit (session) comes to a website from a “source” which is not actually a “source”. For example, it can be visit from an email service, where he had a registration activation link.

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

Note: Behind the scenes, Metorik currently uses the fantastic sourcebuster.js library. 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

When viewing a customer profile and segmenting or exporting on the customers page, the customer source comes from when the customer first registered on your store (either through the account page or during the checkout). If they don't have a source at that time, they won't have one set on their profile ever (just on orders they make in the future).

However, for the customer sources report, we group customers by the source of their first order (set during checkout).


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.


Changing the cookie & session times

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 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');
    }
}

Still need help? Contact Us Contact Us