lgraubner / gatsby-plugin-fathom Goto Github PK
View Code? Open in Web Editor NEWGatsby plugin to add Fathom tracking to your site.
License: MIT License
Gatsby plugin to add Fathom tracking to your site.
License: MIT License
This plugin doesn't work any longer, and its deprecation is mentioned in this Github repo's readme and on https://www.npmjs.com/package/gatsby-plugin-fathom, but it is not mentioned in either https://www.gatsbyjs.com/plugins/gatsby-plugin-fathom/ nor https://www.npmjs.com/package/gatsby-plugin-fathom-v2 (which seems like something that ought to work given https://www.npmjs.com/package/gatsby-plugin-fathom being deprecated).
What even is the -v2 npm package? All in all, this is rather confusing...
Fathom now uses [youraccount].usesfathom.com as the analytics domain.
I would be happy to work on a PR fixing this.
If you're paying for Fathom, you can (should?) use Fathom's own hosted version of the tracker script rather than the one hosted by your own instance.
I think it would make sense to default the instance URL to cdn.usefathom.com
and document in the REAMDE
that you can just provide the tracking ID if you're using the hosted version.
If you like that idea, I'd be happy to make a PR that makes those changes!
Issue:
Currently, gatsby-plugin-fathom will log analytics while in the development environment (ie. localhost). This is not ideal as it creates noise in the overall analytics data.
Request:
Implement a domain blacklist which would ensure that analytics are not tracked if Fathom is triggered from a domain on the list.
A example implementation can be found in the Fathom documentation:
https://usefathom.com/support/localhost
Ideally we would be able to configure the list in the gatsby-config.js
, like so:
// gatsby-config.js
module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-fathom',
options: {
// Fathom server URL. Defaults to `cdn.usefathom.com`
trackingUrl: 'your-fathom-instance.com',
// Unique site id
siteId: 'FATHOM_SITE_ID',
// Domain Blacklist
fathomExcludeHostnames: ['localhost']
}
}
]
}
The current tracking code used by this plugin is not the latest tracking code and doesn't support new fathom features such as fathom.blockTrackingForMe()
.
I would like to work on a pull request for this, I think adding an option to allow site owners to choose between the old embed code and new one is the most appropriate route. Does anyone have any opinions on this?
When printing out the tracking snippet in the gatsby-ssr.js file, you could add an html comment like:
<!-- Fathom - simple website analytics - https://usefathom.com/ref/{your referral code maybe} for $10 off -->
<!-- Why you'll love using Fathom over Google Analytics:
- You don't need to display those pesky cookie notices as Fathom doesn't use cookies, nor do they track invasive data.
- Fathom offers simple, straight-forward website analytics.
- Fathom is focused on privacy for website visitors, they don't track them, save their personal information, or need it to be profitable.
- Fathom has hundreds of customers and track tens of millions of page views per month, so they might be a small company, but are doing big things.
- Fathom can handle viral content without breaking a sweat, so your site won't slow down because of them, and they don't ever stop tracking you because of a spike in popularity.
- All of their plans allow for **unlimited** websites to be tracked
-->
Now you could either:
This plugin doesn't work any longer, and its deprecation is mentioned in this Github repo's readme and on https://www.npmjs.com/package/gatsby-plugin-fathom, but it is not mentioned in either https://www.gatsbyjs.com/plugins/gatsby-plugin-fathom/ nor https://www.npmjs.com/package/gatsby-plugin-fathom-v2 (which seems like something that ought to work given https://www.npmjs.com/package/gatsby-plugin-fathom being deprecated).
What even is the -v2 npm package? All in all, this is rather confusing...
For the simple snippet, we can use
<script src="https://cdn.usefathom.com/3.js" site="###"></script>
<script>
window.fathom || document.write('<script src="###/core.js"><\/script>');
</script>
If we were to use trackingUrl
we would be greeted with a TypeError: e is null
var e = document.querySelector('script[src*="cdn.usefathom.com"]'),
t = {
siteId: e.getAttribute('site'),
spa: e.getAttribute('spa'),
trackerUrl: '###'
};
Any idea on how to bypass adblockers?
How can I add preconnect and dns-prefetch with this plugin?
It's recommended by the Lighthouse tool.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.