Install Chartsy on Next.js
Add the script to the root layout (App Router) or _document (Pages Router).
1Add the script to your root layout
Copy your snippet from Growth Attribution in the Chartsy sidebar: step 1 of Set up tracking has it with your site's public key, which is safe to expose:
App Router. Render it in the <head> of app/layout.tsx, which wraps every page:
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head>
<script
async
src="https://chartsy.fra1.digitaloceanspaces.com/production/static/track.js"
data-key="ch_pk_..."
data-api="https://dashboard.chartsy.app/api/attribution"
/>
</head>
<body>{children}</body>
</html>
);
}Pages Router. Put the same tag in pages/_document.tsx:
import { Html, Head, Main, NextScript } from 'next/document';
export default function Document() {
return (
<Html lang="en">
<Head>
<script
async
src="https://chartsy.fra1.digitaloceanspaces.com/production/static/track.js"
data-key="ch_pk_..."
data-api="https://dashboard.chartsy.app/api/attribution"
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}Client-side navigation with <Link> doesn't reload the script - which is correct, since Chartsy counts one visit per session, not per page.
Visits, sources and signups are fully tracked. The one thing client-side navigation leaves out is the "pages before signup" journey, which only includes full page loads.
2Check it worked
Open your deployed site in a private window, then in Chartsy go to Settings → Domains and click View setup checklist on the site's row. "Add tracking snippet" flips to done as soon as the first visit lands - it is inferred from real traffic, so it confirms the snippet is firing, not just pasted.
Nothing arriving? View the page source and confirm the <script> tag is there with your real key. A blank or placeholder key is the most common cause.
Testing locally records nothing: the script ignores localhost and private IP addresses. Automated browsers (Playwright, Puppeteer, Selenium, headless Chrome) are ignored too, so automated tests won't show up in your reports.
3Track signups
The script now records where each visitor came from. To see which channels bring signups - and later revenue - tell Chartsy who signed up.
Other stacks: see all signup tracking guides.


