Last active
March 19, 2022 16:59
-
-
Save lostdesign/d6f17fd56c2dffdc82a9a5f40ed1eb75 to your computer and use it in GitHub Desktop.
This is a quick snippet to embed fathom into a nuxt3 site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add this as plugins/fathom.client.js and | |
* you are good to go - nothing else tod o. | |
*/ | |
import * as fathom from 'fathom-client' | |
export default defineNuxtPlugin(nuxtApp => { | |
fathom.load('YOUR-SITE-ID', { | |
spa: 'history' | |
}) | |
nuxtApp.provide('fathom', fathom) | |
addRouteMiddleware('fathom', () => { | |
fathom.trackPageview() | |
}, { global: true }) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment