Using Fathom to track Shopify conversions

Fathom is a privacy and simplicity focused alternative to tools such as Google Analytics. I am using Fathom with Shopify to try and build a baseline I can use to compare my more advanced analytics tools against.

Adding the tracking of purchases to the order success page is really easy. Make your event in Fathom, then add the following script to your Shopify store under Settings > Checkout > Order status page > Additional scripts.

1
2
3
4
5
6
7
8
9
10
11
12
<script src='https://cdn.usefathom.com/script.js' data-site='XXXXXXXX' defer></script>

{% if first_time_accessed %}
  <script>
    (function () {
      window.addEventListener('load', (event) => {
        fathom.trackGoal('XXXXXXXX', Math.round('{{ total_price | money_without_currency }}' * 100));
      });
    })();
  </script>
{% endif %}

The first_time_accessed directive ensures that the contents will only be triggered when the order status page is accessed for the very first time, eliminating potential double counting.

We pass the total_price through money_without_currency to strip any currency symbols and then multiply by 100 to give us the pence / cent value. We Math.round to ensure we get rid of any potential floating points inaccuracies that may have crept in.