# Add a third-party tracker

Source: https://modulify.ai/docs/grow/custom-code-and-trackers

Run Google Analytics, a pixel or another tracker alongside the built-in visitor analytics.

Google Analytics, Google Tag Manager, the Meta or TikTok pixel, LinkedIn Insight, Hotjar, Clarity, PostHog, Mixpanel and Segment can all run on a Modulify site. You do not paste the snippet into a settings box, because there is no such box. You ask for it in chat and the AI wires it into the site's code.

The built-in [visitor analytics](/docs/grow/analytics) keeps running either way. Adding your own tracker is an addition, never a replacement.

## Before you begin

Have your tracking id ready if you can: `G-` for GA4, `GTM-` for Tag Manager, a pixel id, or the project key your vendor gives you. You can start without it, but the tag will not fire until the real id is in place.

A tracker only reports from the published site, so this only produces data once you publish.

## Ask in chat

Ask for it plainly:

```markdown
Add Google Analytics 4 to the site. My measurement id is G-XXXXXXX.
```

The first time you ask in a conversation, the AI does not build straight away. It tells you what you already have and where it lives, says what a third-party tracker costs you in cookie banners and privacy policy wording, then asks a two-option question: **Add {tracker} as well** or **Keep built-in only**. Pick the first and it builds the whole thing in its next turn.

If your message already shows you know about the built-in analytics, for example "I know you have your own, add GA anyway", it skips the question and builds immediately. If you name several trackers, one option covers all of them together.

## Where the tracking id is stored

The id goes in the project's [Secrets](/docs/data/secrets) tab, not in the code. Open the editor's **More** menu and choose Secrets to see it.

The key must start with `NEXT_PUBLIC_`, for example `NEXT_PUBLIC_GA_ID`. That prefix is not about secrecy, it is what makes the value reach the browser at all. Without it the value stays server-only, and the tag silently never fires.

To add one by hand, type the key in the `KEY` field, the value in the `value` field, choose **Secret** or **Public** from the lock icon dropdown, and press the plus button. A project holds up to 200 secrets. Keys the platform manages itself are rejected with "This key is reserved by the system and cannot be used.", and a tracking id is never one of those.

If you asked for the tracker before you had the id, the AI creates the key with the placeholder value `REPLACE_ME` and wires everything else up. Nothing loads while the placeholder is there. Paste your real id over it, then publish.

## Publish to make it live

The value is baked in when the site is built, so a tracker only starts counting on the next publish. That is also true after you replace a placeholder id: change the secret, publish, and it counts from then on.

Nothing is tracked in the preview, by your tracker or by the built-in one.

## Your consent banner

The built-in analytics is cookieless, which is why your site needs no consent banner for it. A third-party tracker is a different matter: it sets cookies and sends visitor data to that company, so you need a cookie banner and a privacy policy mention for EU and UK visitors.

The AI offers once, at the end of the build, to add a cookie-consent banner that holds the tracker until the visitor accepts. Say yes and it builds it. It is an offer, not a condition.

Expect the two sets of numbers to disagree. They count visits differently, and they never match exactly.

## What stays out of your hands

- **The built-in script.** It is injected at publish time and is not in your project files. The AI will not remove it, edit it, or swap it for yours. The **Collect visitor analytics** toggle in the Analytics tab's Settings is the only off switch, and it is yours.
- **A nonce-based Content Security Policy.** The AI avoids introducing one while wiring a tracker, because it would block the built-in script and quietly stop your own stats.
- **The Built with Modulify badge.** Hiding it in code is refused. It is a paid toggle in the project's [Settings](/docs/editor/settings) tab.

## Next

- [Visitor analytics](/docs/grow/analytics) is the built-in dashboard your tracker sits alongside.
- [Publish a site](/docs/publish/publish-a-site) is what makes any of it start counting.
- [SEO and AI search](/docs/grow/seo) covers being found before you measure it.