Skip to content

Instantly share code, notes, and snippets.

@lostdesign
Last active March 19, 2022 16:59
Show Gist options
  • Save lostdesign/d6f17fd56c2dffdc82a9a5f40ed1eb75 to your computer and use it in GitHub Desktop.
Save lostdesign/d6f17fd56c2dffdc82a9a5f40ed1eb75 to your computer and use it in GitHub Desktop.
This is a quick snippet to embed fathom into a nuxt3 site.
/**
* 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