WordPress
There are two ways to add the Antlytics snippet to a WordPress site. Pick the one that matches how you manage your theme.
Prefer the hosted tracker.js snippet below (or the Antlytics WordPress plugin 1.1.0+). Both load the same CDN tracker so pageviews, engagement, and SPA navigations stay current.
Prerequisites
- An Antlytics account and at least one site created in your dashboard
- The tracking ID (UUID) from Settings → Tracking Snippet
- Administrator access to your WordPress site
Option A — Theme editor (classic themes)
If you are using a classic (non-block) theme and have access to the theme editor:
- In your WordPress admin, go to Appearance → Theme File Editor.
- Open
header.phpfrom the file list on the right. - Locate the closing
</head>tag. - Paste the snippet immediately before
</head>:
<script
defer
src="https://www.antlytics.com/tracker.js"
data-tracking-id="YOUR_SITE_ID"
data-api-host="https://www.antlytics.com"
></script>
- Replace
YOUR_SITE_IDwith your tracking ID from the Antlytics dashboard. - Click Update File.
Note: If you update your theme, the edit to
header.phpmay be overwritten. Use a child theme or switch to Option B to avoid losing it.
Option B — Header-scripts plugin (block themes or safer alternative)
If you are using a block theme (e.g. Twenty Twenty-Four) or want a change that survives theme updates, use a plugin that adds code to your site's <head>. Search the WordPress plugin directory for "header footer scripts" or "custom head code" — there are several free options.
Once installed:
- Open the plugin's settings page.
- Paste the snippet (with
YOUR_SITE_IDreplaced) into the header or<head>field. - Save. No need to touch any theme files.
Caching plugins
If your site uses a caching plugin (e.g. WP Super Cache, W3 Total Cache, WP Rocket), the script tag is static HTML and requires no special configuration — it will be cached along with the rest of the page and will still fire correctly in the browser. No special exclusion rules are needed.
Verify data is flowing
Visit your live WordPress site in a browser, then check the real-time count in your Antlytics dashboard. Data appears within seconds.
Also confirm the site URL in Antlytics matches how visitors reach you (for example https://themortgageroom.com.au vs https://www.themortgageroom.com.au). Hostname shields and strict origin use that URL.
Troubleshooting
- Open the browser Network tab and look for a
POSTto/api/ingest/pageview. A200response means the snippet fired correctly. - On hide or unload you should also see a request to
/api/ingest/engagement(scroll depth + active time). If pageviews succeed but engagement shows a CORS error aboutAccess-Control-Allow-Origin: *, hard-refresh so the browser loads the latesttracker.js, or update the Antlytics WordPress plugin to 1.1.0+. - Confirm the tracking ID matches Settings → Tracking Snippet in your Antlytics dashboard.
- Test in an incognito window if you have an ad blocker installed, or set up the first-party proxy.
See Troubleshooting for more common issues.