Guide

Umami not tracking on WordPress: how to fix it

When Umami shows nothing, too little or too much, the cause is usually one of a short list. This page goes through them by symptom, with a way to check each one before you change anything.

Last updated

Short answer

If Umami is not tracking your WordPress site, open the site in a private window and view the page source. The Umami script tag should be there once, with the correct data-website-id. Then check the browser's Network tab for a request to your Umami host. The usual causes are a missing or wrong tag, a page cache serving old pages, an ad blocker, or a setting that delays JavaScript.

Start here: check Umami tracking in five steps

Do these in order.

  1. Open your site in a private window

    You are logged out there, so no administrator exclusion applies. Turn off ad blocking and tracking protection for the test.

  2. Look for the script tag

    View the page source and search for data-website-id. It should appear once, with the ID shown in Umami under Websites → Edit → Tracking code.

  3. Watch the Network tab

    Open the developer tools (F12), select Network and reload. The script, usually script.js, should load without an error, followed by a request ending in /api/send, the default path. On Umami Cloud that request goes to gateway.umami.is.

  4. Check Realtime in Umami

    Your visit should appear under Realtime within a few seconds.

  5. Read the plugin's status panel

    In Connect for Umami, the panel at the top of Settings → WPUmami shows whether the script URL responds and whether the stats API accepts your credentials. Check again re-runs both checks.

Browser console: four checks in one command
// Run this in the console on your own site.
console.log({
	// "1" means Umami's browser flag is set.
	umamiDisabled: localStorage.getItem('umami.disabled'),
	// "1" means your browser sends Do Not Track.
	doNotTrack: navigator.doNotTrack,
	// Must be listed in data-domains, if the tag has that attribute.
	hostname: location.hostname,
	// Number of Umami script tags on the page. It should be 1.
	umamiTags: document.querySelectorAll('script[data-website-id]').length
});

Umami shows no visits at all

CauseHow to checkFix
The script is not on the pageNo data-website-id in the page sourceAdd the tracking code. In Connect for Umami, fill in both the website ID and the script URL
Wrong website IDThe ID in the source differs from the one in UmamiCopy it from Umami again
Page cache serving old pagesYour settings are saved, but the tag is still missing in a private windowClear the page cache and any CDN cache
Ad blocker or privacy browserThe Network tab shows the script or the /api/send request as blockedTurn it off to test. For visitors, Umami recommends proxying the script and endpoint through your own domain and setting data-host-url
Script URL unreachableThe URL does not show JavaScript when opened in a browser tab. The plugin's panel reads "On, but the script URL is not responding"Correct the URL, use https://, and check that your Umami instance is running

Your own visits are missing

CauseHow to checkFix
Administrator exclusionThe tag is missing while you are logged in and present in a private windowWorking as intended: "Exclude logged-in admins" is on by default in Connect for Umami. Untick it to be counted
The umami.disabled flagThe console check shows umamiDisabled: "1"Run localStorage.removeItem('umami.disabled'); in the console
Do Not TrackThe tag has data-do-not-track="true" and the console check shows doNotTrack: "1"Turn off Do Not Track in your browser, or "Respect Do Not Track" on the site

Connect for Umami also never tracks draft previews or the Customizer. More in the guide to excluding your own visits.

Some visitors are missing

CauseHow to checkFix
JavaScript delayed until interactionThe Umami script loads only after you move the mouse, scroll or tapExclude the Umami script from that optimization feature. Until then, visits with no interaction are not counted
data-domains does not match the hostnameCompare it with hostname in the console check. www.example.com and example.com are differentList every hostname, for example example.com,www.example.com. In the plugin, use the Domains field
Content Security PolicyThe console shows a Content Security Policy error naming the Umami hostAllow the script host in script-src and the data host in connect-src
Content Security Policy: sources to add for Umami Cloud
script-src 'self' https://cloud.umami.is;
connect-src 'self' https://gateway.umami.is;

Add these to the policy you already have. On self-hosted Umami, use your own Umami host in both. With data-host-url set, connect-src needs that host instead.

Every pageview is counted twice

The script is on the page more than once, for example pasted into a theme's header field and also added by a plugin or snippet. Each copy sends its own pageview. Search the source for data-website-id, or look at umamiTags in the console check: it should be 1. Remove every copy but one, then clear the page cache.

The dashboard widget says "Disconnected from Umami"

The Connect for Umami widget reads stats through the Umami API, which is separate from tracking, so a widget error does not by itself mean tracking has stopped. The reason appears in the widget and in the status panel next to Stats API. Fix it on the Dashboard tab, then click Check again.

Connect for Umami messages and what to do

MessageCauseFix
"Umami refused the request (HTTP 401). Check that the API key or login is correct and is allowed to view this website." Also shown with 403The key or login is wrong or revoked, or that user is not allowed to view this websiteCreate a new API key in Umami under Settings → API keys, with a user who can view the website, and paste it in
"This Umami user has two-factor authentication turned on, which a server-side login can’t complete. Use an API key instead."You connected with a username and password, and that user has two-factor authentication onConnect with an API key
"Umami login failed. Check the API URL, username and password."Wrong username or password, or the API URL is not your Umami instanceEnter them again, or use an API key
"Umami API returned an unexpected response. Check the API URL." or a message starting "Umami API returned HTTP 404"The API URL does not point at the Umami APIUse the address of your Umami instance with no path, such as https://analytics.example.com, or leave it blank to reuse the script host. Umami Cloud is detected automatically
"The saved API key or password can no longer be read, usually because the security keys in wp-config.php changed. Enter it again."The credentials are encrypted with a key derived from those security keysEnter the API key or password again and save

Widget figures are cached for five minutes. "Check again" clears that cache.

Frequently asked questions

Why is Umami not showing any visitors on my WordPress site?

The usual causes: the script tag is missing from the page, the website ID is wrong, a page cache is serving pages without the tag, or your own browser is blocking it. View the page source in a private window and search for data-website-id.

Why does Umami not count my own visits?

Three things leave you out on purpose: an administrator exclusion in WordPress (on by default in Connect for Umami), the umami.disabled flag in your browser, and Do Not Track if the site respects it.

Do ad blockers stop Umami from counting visits?

They can. Visitors who block the script are not counted, and Umami excludes bots by default, so it can read lower than server logs. Umami recommends proxying the script and the collection endpoint through your own domain and setting data-host-url, which is the Host URL field in Connect for Umami.

Why is Umami counting every pageview twice?

The tracking script is on the page twice, for example pasted into the theme and also added by a plugin. Search the page source for data-website-id and remove every copy but one.

How do I fix "Umami refused the request (HTTP 401)" in Connect for Umami?

Umami did not accept the saved API key or login for this website. Create a new API key in Umami under Settings → API keys, paste it on the Dashboard tab of Settings → WPUmami, save, and click Check again.

Connect WordPress to Umami in about two minutes

One plugin: the tracking script, events, store revenue and your stats inside WordPress. Plans start at $12 a year, with a 14-day money-back guarantee.

See pricing