WordPress
If you have a WordPress website, you can either copy/paste your Fathom script into your footer theme file, or use our WordPress plugin.
By using Fathom Analytics for WordPress you can view your Fathom dashboard directly within your WordPress admin area (cool, right?).
In order to show your Fathom dashboard inside WordPress, your dashboard has to be shared.
Hereâs how you set it up:
- Download the Fathom Analytics plugin
- Log into your WordPress admin area
- Go to
Plugins,Add New - Search for
Fathom Analytics - Click
Install Now, thenActivate - Go to
Settings, thenFathom Analytics - In the
Site IDfield, type in your Site ID. If you donât know your Site ID, log into Fathom, go toSettings, click on your site name, and your Site ID will be located below the site name - If your dashboard is public, leave the
Fathom Share Passwordfield blank. If your dashboard is privately shared with a password, then type in the share password Note: site sharing must be enabled for you to view your dashboard within WordPress - To prevent Fathom from collecting visit data for logged-in WordPress users, check the boxes for the user roles you want to exclude. Leave them unchecked if you donât want to exclude any roles.
- To display your Fathom dashboard within WordPress, ensure the
Display Analytics Menu Itemcheckbox is selected. - Click
Save Changes, and youâll find theFathom Analyticsoption in the menu on the left-hand side of your WordPress admin area.
Following the above steps will automatically place the Fathom script into the header of every page on your WordPress site.
Download Fathom Analytics for WordPress here.
If your WordPress site isnât displaying new analytics data, even after youâve installed our plugin, read this
WordPress can sometimes be tricky because there are many moving parts (plugins, themes, extra code, etc). If youâve installed our plugin, and followed the setup instructions above, and you still arenât seeing analytics data on your dashboard, itâs likely due to one of these things:
- Youâre using a caching plugin. See the section below on caching/optimizer plugins. If yours isnât listed, look for a way within that plugin to âexcludeâ our script from being cached, as our script loads from our servers, not from your local install (thatâs why our script is so fast).
- Youâre using a plugin that combines our javascript with local scripts. See the section below on caching/optimizer plugins. If yours isnât listed, look for a setting in that plugin to âexcludeâ our script from being combined with any other javascript, as our script will not work if itâs combined with local scripts (since itâs not local).
- Youâre using a plugin that is minifying our javascript with local scripts. See the section below on caching/optimizer plugins. If yours isnât listed, look for a setting in that plugin to âexcludeâ our script from being minified with any other javascript, because our script will not work if itâs minified locally (since itâs not local).
To exclude our script from any of the above scenarios, add cdn.usefathom.com/script.js to the exclusions.
If you are not seeing your own visits to your site:
- Make sure you havenât excluded your user role by going to the Fathom settings in your WordPress admin area and checking whether you have selected your user role option under
Exclude Roles. - Make sure you havenât blocked your IP in your site firewall settings.
- Make sure you havenât blocked yourself in your browser console.
The Fathom Analytics dashboard page is showing a 404 error in WordPress
If you are seeing a 404 page when trying to view your dashboard from within WordPress, itâs because you havenât either havenât set your dashboard to shared in your siteâs settings or you havenât entered the password into the Share password field (see step 8 from the setup instructions above).
WordPress caching and site optimizer plugins that are auto-excluded from caching the Fathom Analytics script:
In the past, weâve had issues with certain 3rd-party WordPress plugins caching our script, causing it to not function correctly. So, weâve implemented a way for our script to avoid being cached and/or bundled by those plugins.
Hereâs the list of caching plugins from which our script is automatically excluded:
- WP Rocket
- SiteGround Optimizer
- Hummingbird
- W3 Total Cache
- WP Optimize
Track custom events for authors
If youâd like to know which authors are getting the most traffic on your site, you can setup a custom event and add a snippet to your functions.php theme file to track this. The code below will create a custom event per author (once each author has more than 1 pageview) and add an event completion each time a post (not pages) has been viewed, and organize each post view by author in your events:
function add_fathom_author_tracking() {
if (is_single()) {
$author_nickname = get_the_author_meta('nickname');
?>
<script>
window.addEventListener('load', (event) => {
fathom.trackEvent('Author: <?php echo esc_js($author_nickname); ?>');
});
</script>
<?php
}
}
add_action('wp_footer', 'add_fathom_author_tracking');
The above assumes you have access to edit the functions.php file in your theme. If youâre using a theme that doesnât allow editing that file, a plugin like Code Snippets can help (note that we cannot support plugins like this one, itâs out of scope of our Fathom support). The above code does not track tag pages, category pages, archive pages, or non-single post pages. It will only track blog post pages with authors.
Further customization
To learn about all the options we offer, read our advanced documentation here.