Skip to content

📈 Add Fathom tracking to Next.js projects that use the App Router.

License

Notifications You must be signed in to change notification settings

joshuabaker/next-fathom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Next Fathom

Next Fathom

Next Fathom is a component wrapper around fathom-client that allows you to quickly and easily add Fathom Analytics to your Next.js projects that use the App Router.

Installation

To install the package using npm, run the following command in your terminal:

npm install next-fathom

Alternatively, if you are using yarn, use the following command:

yarn add next-fathom

Usage

In your layout, import and add the Fathom component, and add your Site ID to the siteId prop. This will load the Fathom client and track page views automatically.

import { Fathom } from "next-fathom";

export default function RootLayout({ children }) {
  return (
    <html lang="en">
    <body>
    <Fathom
      siteId={"MY_FATHOM_ID"}
      options={{ includedDomains: ["example.com"] }}
    />
    {children}
    </body>
    </html>
  );
}

Other methods

This package also re-exports everything from the fathom-client package (e.g. trackGoal). See the fathom-client readme for how to use these.

Referrals

If you’ve not yet signed up you can use my referral link to get $10 credit.

Get $10 credit for Fathom Analytics