Before you start
- A paid plan that includes AI Traffic, and project management permission. See Set up AI Traffic.
- Access to edit your site’s pages or template.
Generate the snippet
- Open your project
- Open Settings › Integrations
- Select Set up beside Tracking snippet under Website analytics
- Select Generate tracking snippet
Install the snippet
Copy the snippet and add it to your website’s layout or template file so it loads on every page. The snippet should be placed before the closing</body> tag.
The copied snippet is a complete <script> element: it starts with <script> and ends with </script>. Paste it as copied wherever a page accepts HTML. Don’t wrap it in another <script> tag, or the browser reports a syntax error and the snippet never runs.
GitBook
If your documentation is hosted on GitBook, you can use the official DevTune integration instead of manually installing the snippet:- Go to your GitBook space settings
- Navigate to Integrations
- Find and install the DevTune integration from the marketplace
- Enter your project snippet key when prompted
Next.js
Add the snippet to your root layout,app/layout.tsx. The Script component writes its own <script> tag, so paste only the code between the snippet’s <script> and </script> tags, not the tags themselves:
Script element to pages/_app.tsx.
WordPress
Add the snippet to your theme’sfooter.php file, or use a plugin such as “Insert Headers and Footers” to add it to the footer section.
Webflow / Squarespace
Go to Site Settings, then Custom Code, and paste the snippet in the Footer section.Plain HTML
Paste the snippet as copied, tags included, just before the closing</body> tag in your HTML template:
Check the snippet is working
- Open a page on your site in a browser with ad blockers turned off.
- In Settings › Integrations, reload the page. Until DevTune accepts the first page view, the Tracking snippet row reads Configured. Within a few minutes it reads Active, with Last ingest and a time, and lists the page’s hostname.
If something goes wrong
If the row stays Configured, check:- The snippet is present in your page source
- The snippet key matches the one shown in Settings › Integrations
- Ad blockers are not blocking the request. If they are, proxy the snippet through your domain.
- Snippet and middleware collection is switched on in Settings › Integrations
Enable or disable tracking
In Settings › Integrations, use the Snippet and middleware collection switch to enable or disable tracking at any time. The switch controls both the snippet and edge middleware; to stop only one, remove it from your site. When disabled, incoming events are rejected and no new data is recorded.Rate limits
Each tracking snippet accepts up to 10,000 requests per minute. This is enough for most sites. If your site exceeds this limit, excess requests are silently dropped.Multi-site tracking
You can use the same tracking snippet across multiple websites or subdomains. Every site reports into the same project, and Insights › AI Traffic shows the total. To read one site on its own, pass its host in thedomain query parameter of the AI Traffic API — for example /api/v2/projects/{projectId}/traffic/summary?domain=docs.example.com. To read one path and its descendants, also pass pathPrefix — for example domain=example.com&pathPrefix=/blog.
Proxy setup
You can proxy the tracking endpoint through your own domain when you need first-party routing for your deployment setup, or when ad blockers drop the third-party beacon. This applies to the snippet only — the crawler sensors do not use it. Teams should still honor consent requirements and local privacy rules before collecting traffic data. Instead of the snippet sending data tohttps://devtune.ai/api/v1/llm-traffic/collect, you configure a reverse proxy, so requests go to a path on your own domain.
-
Add a reverse proxy from
/dt/on your domain tohttps://devtune.ai/api/v1/llm-traffic/. Examples for common hosts follow. -
Change the beacon URL in your snippet to your proxy path. Find it in the
navigator.sendBeaconcall: - Check the snippet is working.
Vercel / Next.js
Add a rewrite tonext.config.ts:
Netlify
Add tonetlify.toml:
Cloudflare
Create a Worker route on/dt/* that forwards each request to the same path under https://devtune.ai/api/v1/llm-traffic/.
nginx
Next steps
- Set up AI Traffic - connect a crawler sensor, website analytics and Search Console
- Reading AI Traffic - what each view counts