Documentation tools
Add Loogika to Fumadocs
You add Loogika to Fumadocs in the root layout, app/layout.tsx, with the Script component from next/script. Fumadocs builds documentation sites on top of Next.js, and the root layout wraps every page. One tag there covers the docs routes and every page outside them.
Last updated .
What do you need before you start?
Copy your script tag from Site Settings in Loogika, under the Tracking Script tab. It looks like this, with your own 12-character site ID in place of YOUR_SITE_ID:
<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
In Fumadocs you use the address from the src attribute. The Script component of Next.js builds the tag for you.
How do you add Loogika to the Fumadocs root layout?
Open app/layout.tsx and render Script inside the body. Fumadocs has already placed a RootProvider in the body, and the Script component sits beside it.
import { RootProvider } from "fumadocs-ui/provider/next";
import Script from "next/script";
import type { ReactNode } from "react";
export default function Layout({ children }: { children: ReactNode }) {
return (
<html lang="en" suppressHydrationWarning>
<body className="flex flex-col min-h-screen">
<RootProvider>{children}</RootProvider>
<Script
src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID"
strategy="afterInteractive"
/>
</body>
</html>
);
}
Replace YOUR_SITE_ID, then build and deploy the site as you normally do.
Why the root layout and not the docs layout?
The docs layout only wraps the pages under /docs. A tag in app/docs/layout.tsx therefore misses a landing page that sits outside that folder. The root layout in app/layout.tsx wraps both, so your reports show visitors who move from the landing page into the docs.
Does Loogika count page changes between docs pages?
Yes. A Fumadocs site changes pages in the browser without a full page load. Loogika records each of those route changes as a pageview when SPA Navigation is on in Site Settings. The setting is on for a new site.
The script waits 500 milliseconds after a route change before it records the pageview. A redirect inside the app is then counted once.
Where do you find more about Next.js?
The Next.js guide applies to Fumadocs as well, because a Fumadocs site is a Next.js app. It covers the Script component in more detail and shows how to send custom events from client components.
How do you check that Loogika is installed?
Load your deployed site in a fresh browser tab and visit a few docs pages. The pageviews show up in the Loogika dashboard within a few seconds.
If nothing arrives, open the page source and look for script.js?siteId=. When only the pages under /docs report data, the tag sits in the docs layout. Move it to the root layout. The script troubleshooting page lists other causes.