AI referral traffic
Install a site snippet, attribute visits from AI assistants, and read the data on Public API v2.
AI referral traffic
Measure visits that arrive on your domain from ChatGPT, Gemini, Claude, Perplexity, Copilot, and other AI assistants.
MencionAI already tracks whether models cite or recommend your brand. AI referral traffic answers a different question: did humans click through to your site?
How it works
- Create a site key in Settings → AI Traffic (or the AI traffic script accordion under API Keys).
- Paste the install snippet on your site (or load it via Google Tag Manager / RD Station).
- The snippet posts
document.referrerand optional UTMs to Public API v2POST /v2/traffic/ingest. - Command Center and the API show visits by AI source.
Important: ChatGPT and Gemini usually do not append UTMs. Attribution relies on the HTTP referrer when present. Some clicks arrive as Direct (“dark AI traffic”) and will be under-counted.
Install snippet
Copy the ready-made snippet from Settings → AI Traffic. It looks like:
<script
async
src="https://www.mencionai.com/t.js"
data-site="YOUR_SITE_KEY"
data-endpoint="https://api.mencionai.com/v2/traffic/ingest"
></script>
Replace YOUR_SITE_KEY with the full msk_… value from Settings (or copy the block already filled in for you).
Verify
- Open your site with DevTools → Network.
- Confirm a
POSTto/v2/traffic/ingestreturns200. - In Settings → AI Traffic, use Check install, or wait until status shows Receiving traffic after the first successful ping.
Google Tag Manager (recommended for marketing teams)
- Tags → New → Custom HTML.
- Paste your snippet from Settings.
- Trigger: All Pages (or the pages you want to measure).
- Submit and publish the container.
- Use GTM Preview to confirm the tag fires.
Plain HTML / header
Paste the snippet before </head> on every template you care about (or in a shared layout partial).
Next.js (App Router)
In app/layout.tsx (or your root layout):
import Script from 'next/script';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<Script
src="https://www.mencionai.com/t.js"
strategy="afterInteractive"
data-site="YOUR_SITE_KEY"
data-endpoint="https://api.mencionai.com/v2/traffic/ingest"
/>
</body>
</html>
);
}
If data-* props are awkward with next/script in your version, use a raw <script async …> in the layout instead.
WordPress
Very common for Brazilian content and lead-gen sites.
- Theme: paste into
header.phpbefore</head>, or - Plugin: use “Insert Headers and Footers” / WPCode / similar, or
- GTM: load via your existing Tag Manager plugin (then follow the GTM steps above).
Publish/clear cache (LiteSpeed, WP Rocket, Cloudflare) after installing.
Shopify
- Online Store → Themes → Edit code →
theme.liquid→ paste before</head>, or - Settings → Customer events / additional scripts if your plan supports it.
Webflow
Project Settings → Custom Code → Head Code → paste the snippet → Publish.
React / Vite SPA
Add the snippet to index.html inside <head>, or inject once in your app bootstrap so it runs on first load.
RD Station Marketing
Common in Brazil when the marketing team already injects tags.
- Open RD Station → settings for site tracking / custom scripts (or your GTM container linked to RD Station).
- Add a custom HTML / custom script block with the MencionAI snippet (same as GA4 or Meta Pixel installs).
- Apply to all pages (or the funnel pages you care about).
- Publish and verify with Network →
POST …/traffic/ingest.
If RD Station only hosts GTM for you, install via Google Tag Manager instead.
ActiveCampaign / other tag managers
Same pattern as GTM or RD Station: Custom HTML / custom script on All Pages. Do not put organization API keys (mak_…) in the browser.
Brazil ecommerce platforms
Nuvemshop (Tiendanube)
- Admin → Online store → Preferences / Scripts (or My apps → custom code, depending on plan).
- Paste the snippet in the header / head scripts field.
- Save and open the storefront once to verify ingest.
If your plan only allows apps: install via Google Tag Manager connected to the store.
Loja Integrada
- Admin → Layout → Código HTML / Scripts (or Configurações → custom codes).
- Paste the snippet in the head section.
- Save, clear any cache, and verify Network → ingest.
Tray Commerce
- Admin → Configurações → Códigos e SEO / Scripts personalizados (labels vary by Tray version).
- Add the snippet to the header.
- Save and test on the live storefront.
VTEX
- Use Google Tag Manager (most common on VTEX IO / CMS), or
- Storefront / CMS custom HTML in the head for the pages you measure, or
- A pixels/scripts app if your account already centralizes third-party tags there.
Prefer sitewide GTM so checkout and landing templates stay covered.
Magento / Adobe Commerce
- Add the snippet in the theme
default_head_blocks.xml/ head template, or - Use a “Custom Scripts / Magento GTM” extension and install via GTM.
Wix / Landpages (Hotmart, Eduzz, Braip, etc.)
- Wix: Settings → Custom Code → Head → All pages → paste snippet.
- Checkout / member landpages: if the platform allows “custom head / tracking pixels”, paste the same snippet; otherwise load it from GTM on those domains (register the landpage domain as your project domain or a matching allowlisted host).
Privacy note
The MVP snippet is cookieless (sessionStorage only, no raw IP in the product path). Your legal/consent banner policy still applies if you combine it with other marketing tags.
API v2
| Method | Path | Auth |
| --- | --- | --- |
| POST | /v2/traffic/ingest | Site key (msk_…) in body or X-MencionAI-Site-Key |
| GET | /v2/workspaces/{id}/traffic/summary | API key + workspaces:read |
| GET | /v2/workspaces/{id}/traffic/series | API key + workspaces:read |
| POST | /v2/workspaces/{id}/traffic/site-key | API key + workspaces:write |
Never put organization API keys (mak_…) in the browser snippet.
