Skip to main content
Support home / Integrations

WooCommerce

Before you can start collecting WooCommerce sales data, you will need to add the Fathom script to your site. To do that, follow our WordPress guide

Collecting data for purchases

  1. First of all, you will need the Code Snippets WordPress plugin if you don't already have it installed
  2. Once it's installed, click 'Snippets' in the admin sidebar
  3. Click Add New snippet
  4. Make sure the Function tab is selected, and then paste the following code into the textbox:

Note: Make sure to replace the dummy Event Name in the example with your desired Event Name

add_action( 'woocommerce_thankyou', 'sales_order_tracking' );
 
function sales_order_tracking( $order_id ) {
// Get the order details
$order = wc_get_order( $order_id );
 
// Convert the order total to cents
$order_total = $order->get_total() * 100;
 
// Trigger the event on page load and add the order total to the event
?>
<script>
window.addEventListener('load', (event) => {
fathom.trackEvent('YOUR-EVENT-NAME', {
_value: '<?php echo $order_total ?>',
});
});
</script>
<?php
}
  1. Click Save changes and activate and your event will now start collecting data on each successful order, including the total order price
  2. To check if your event is working, create a successful order and navigate through to the thank you/success page. Once you have done that, check your Fathom dashboard to see if the event completion and the relevant value was recorded


If you still have questions or require help with anything, please reach out to us and we'll happily get things sorted out for you.


Can't find what you're looking for?