Quick start — vanilla snippet
Works with any site: Next.js, plain HTML, WordPress, or anything else that lets you add a script tag to the page <head>.
1. Copy your tracking ID
In your Antlytics dashboard, go to Settings → Tracking Snippet. The snippet is pre-filled with the tracking ID for the currently selected site in the sidebar.
2. Add the snippet to your site
Paste the snippet into every page you want to track, inside the <head> tag. Replace YOUR_TRACKING_ID with your actual UUID.
The block below matches what the dashboard generates for your app base URL (including UTM parameters read from the page query string):
<script>
(function(){
var t="YOUR_TRACKING_ID",u="https://www.antlytics.com/api/ingest/pageview",k="ant_sid";
function sid(){try{var s=sessionStorage.getItem(k);if(s)return s;s=crypto.randomUUID();sessionStorage.setItem(k,s);return s;}catch(e){return crypto.randomUUID();}}
function utm(){try{var p=new URLSearchParams(location.search),o={};["utm_source","utm_medium","utm_campaign","utm_term","utm_content"].forEach(function(k){var v=p.get(k);if(v)o[k]=v;});return o;}catch(e){return {};}}
function s(){fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},keepalive:true,
body:JSON.stringify(Object.assign({tracking_id:t,pathname:location.pathname,referrer:document.referrer||undefined,session_id:sid()},utm()))});}
s();window.addEventListener("popstate",s);
})();
</script>
The ingest URL always ends with /api/ingest/pageview on your Antlytics host.
The snippet fires on initial load and on popstate so SPA navigation (for example Next.js client-side routing) is captured automatically. No cookies are set. The session ID lives only in sessionStorage and is cleared when the tab closes.
3. Verify data is flowing
Visit your live site, then open your Antlytics dashboard. The real-time visitor count in the header should update within about half a minute. Full traffic charts refresh when you reload the dashboard.