Localhost tracking
How Rybbit handles traffic from localhost during development
Rybbit does not restrict tracking to your registered domain — the tracking script works from localhost (or any other origin) out of the box. As long as your snippet has a valid data-site-id, events sent during local development are recorded like any other traffic.
<script
defer
src="https://app.rybbit.io/api/script.js"
data-site-id="YOUR_SITE_ID">
</script>Because localhost traffic is tracked by default, the usual problem is the opposite one: development visits polluting your production analytics. Use one of the approaches below to keep your data clean.
Keeping development traffic out of production data
Option 1: Use a separate development site
Create a second site in your Rybbit dashboard (e.g. "My App (dev)") and use its site ID during development. Your production site's data stays untouched, and you can still verify events end-to-end.
// Next.js example
export function Analytics() {
const siteId =
process.env.NODE_ENV === 'development'
? process.env.NEXT_PUBLIC_RYBBIT_DEV_SITE_ID
: process.env.NEXT_PUBLIC_RYBBIT_SITE_ID;
return (
<script
defer
src="https://app.rybbit.io/api/script.js"
data-site-id={siteId}
/>
);
}Option 2: Only load the script in production
If you don't need analytics while developing, skip loading the script entirely outside production:
// Next.js example
export function Analytics() {
if (process.env.NODE_ENV !== 'production') return null;
return (
<script
defer
src="https://app.rybbit.io/api/script.js"
data-site-id={process.env.NEXT_PUBLIC_RYBBIT_SITE_ID}
/>
);
}// Vanilla JS example
if (process.env.NODE_ENV === 'production') {
const script = document.createElement('script');
script.defer = true;
script.src = 'https://app.rybbit.io/api/script.js';
script.setAttribute('data-site-id', 'YOUR_SITE_ID');
document.head.appendChild(script);
}Option 3: Filter the traffic instead
If you want the script loaded everywhere but excluded from your stats, use your site's exclusion settings — see Filtering Traffic and Hiding Your Own Traffic.
Troubleshooting
Events not showing up from localhost?
- Confirm
data-site-idmatches the site you're looking at in the dashboard - Check the browser console for errors and the Network tab for
POSTrequests to/api/track - Disable ad blockers or privacy extensions — they commonly block analytics scripts on any origin, including localhost
- Make sure the page isn't excluded by your site's IP, path, or user-agent exclusion rules