Multiple site IDs with one website
If you have places on your site that different parties are responsible for, and those parties would like to have different dashboards to collect and filter their stats on, there is quite a smart and simple method of doing this in Fathom Analytics.
Step 1: Create the relevant sites in your Fathom account
First, you will want to set up the necessary number of sites in your Fathom account to obtain each site's Site ID
.
Note: You can use as many Site IDs as you require with this method
Step 2: Disable automatic tracking in Fathom
Next, you must disable automatic tracking for this method to work. You do this by adding data-auto= "false"
to your script. See our advanced script settings section to read more about this. The reason for doing this is that you want to be able to override the script's Site ID on each page.
Step 3: Add the Site ID switching code
In the footer (or in a JS file) of each page that you want to track pageviews on, you will need to add a script that sets the Site ID and fires the "trackPageview()" function to log a view in the dashboard. Here's an example:
On https://example.com/page1
I want all pageviews attributed to the Site ID ABCDEFG
:
<script> window.addEventListener('load', (event) => { window.fathom.setSite('ABCDEFG'); fathom.trackPageview(); });</script>
On https://example.com/page2
I want all pageviews attributed to the Site ID HIJKLMN
:
<script> window.addEventListener('load', (event) => { window.fathom.setSite('HIJKLMN'); fathom.trackPageview(); });</script>
And finally, on https://example.com/page3
I want all pageviews attributed to both the Site ID OPQRSTU
and the Site ID HIJKLMN
:
<script> window.addEventListener('load', (event) => { window.fathom.setSite('OPQRSTU'); fathom.trackPageview(); window.fathom.setSite('HIJKLMN'); fathom.trackPageview(); });</script>
Note: Make sure to replace the dummy Site IDs in the code examples with your own Site IDs
Step 4: Checking it works
Now visit a few pages on your website where you know the Site IDs are different, and then check the relevant Fathom dashboards for those Site IDs to ensure a visit has been reported.
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.