Guide
How to exclude your own visits from Umami on WordPress
Your own visits add pageviews that no real visitor made. There are four ways to leave them out. Each one covers something different, so it is worth knowing all four.
Short answer
To exclude your own visits from Umami, open your website, open the browser console and run localStorage.setItem('umami.disabled', 1); which stops Umami counting that browser on that site. On WordPress you can also leave the tracking script out for logged-in administrators, with a current_user_can() check in functions.php or the "Exclude logged-in admins" switch in Connect for Umami. Self-hosted Umami can ignore IP addresses with IGNORE_IP.
Four ways to exclude your own visits
| Method | What it leaves out | Where it works | Effort |
|---|---|---|---|
Umami's browser flag (umami.disabled) | One browser on one website, logged in or not | Umami Cloud and self-hosted, on any website | One console command per browser and site |
IGNORE_IP environment variable | Every visit from the IP addresses and ranges you list | Self-hosted Umami only | Edit the environment and restart Umami |
current_user_can() check in functions.php | Logged-in administrators, or any role you choose | WordPress sites that load the tracker with PHP | A few lines of PHP to maintain |
| Connect for Umami | Logged-in administrators, draft previews and the Customizer preview, plus staging copies with the Domains setting | WordPress sites using the plugin | None. It is on by default |
You can combine them, for example a WordPress method plus the browser flag on your phone.
Method 1: set Umami's browser flag
This is the method in Umami's own documentation. It works with Umami Cloud and self-hosted Umami, with or without a plugin.
Open your own website
Use the browser you normally browse with. The command has to run on your website, not on the Umami dashboard.
Open the browser console
Open the developer tools (F12 in most browsers, or the browser menu, then More tools → Developer tools) and select the Console tab.
Run the command
Paste
localStorage.setItem('umami.disabled', 1);and press Enter. The Umami tracker sends nothing while this value is set.Check it worked
Reload with the Network tab open. The Umami script still loads, but no request ending in
/api/sendfollows it, and you do not show under Realtime in Umami.Repeat for each browser and each site
The flag is saved in that browser for that website only. Set it again on your phone, in other browsers, and on every site you track.
// Run this in the console while you are on your own website.
localStorage.setItem('umami.disabled', 1);
// Optional check. It should return "1".
localStorage.getItem('umami.disabled');localStorage.removeItem('umami.disabled');The flag lives in the browser's local storage. A private window, another browser, another device, or a browser with its site data cleared all start without it.
Method 2: ignore your IP address (self-hosted Umami only)
If you host Umami yourself, the IGNORE_IP environment variable excludes the addresses you list from data collection. It takes a comma-separated list of IP addresses and CIDR ranges, so one entry can cover an office network. Set it with your other Umami environment variables, then restart Umami.
# Example addresses. Replace them with your own public IP address or range.
IGNORE_IP=203.0.113.10,198.51.100.0/24Know its limits before you rely on it:
- It is set on the Umami server, so it is not available on Umami Cloud.
- It applies to everyone behind that address, on every website the instance tracks.
- Home and mobile connections change address from time to time. When yours changes, you are counted again.
- Umami has to see the visitor's real address. Behind a proxy or load balancer, check Umami's
CLIENT_IP_HEADERandTRUSTED_PROXIESvariables.
Method 3: skip logged-in administrators with code
WordPress knows who is logged in, so it can leave the Umami script off the page for you. If you load the tracker from a child theme's functions.php or a code-snippets plugin, put a capability check in front of the enqueue:
add_action( 'wp_enqueue_scripts', function () {
// Administrators, draft previews and the Customizer are not real visits.
if ( current_user_can( 'manage_options' ) || is_preview() || is_customize_preview() ) {
return;
}
wp_enqueue_script(
'umami',
'https://cloud.umami.is/script.js', // Your script URL.
array(),
null,
array( 'strategy' => 'defer', 'in_footer' => false )
);
} );
// Add the website ID to the script tag.
add_filter( 'script_loader_tag', function ( $tag, $handle ) {
if ( 'umami' !== $handle ) {
return $tag;
}
return str_replace( '<script ', '<script data-website-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ', $tag );
}, 10, 2 );Replace the script URL and website ID with your own. Only administrators have manage_options by default. To leave out editors, authors and contributors too, change it to edit_posts. The strategy option needs WordPress 6.3 or newer.
If you pasted the tracking code into a header-scripts box instead, replace it with this snippet. Do not keep both, or every visit is counted twice.
Method 4: use the switch in Connect for Umami
Connect for Umami makes the same check without code. Under Settings → WPUmami → Tracking, Exclude logged-in admins is on by default: logged-in administrators get no Umami script. Other roles, such as editors and customers, are still tracked. Draft previews and the Customizer preview are never tracked. The plugin's click, form and store events follow the same rule.
Developers can change who is skipped with the cfumami_should_track filter:
add_filter( 'cfumami_should_track', function ( $track ) {
// $track is already false for administrators and previews.
return $track && ! current_user_can( 'edit_posts' );
} );Keep staging and local copies out
A staging or local copy of your site usually carries the same tracking code, so visits to it land in your live stats. In the plugin, enter your live hostnames in Domains under Advanced tracking, for example example.com,www.example.com. That sets Umami's data-domains attribute. Umami compares each value with the hostname in the address bar, so list both the www and the bare version if your live site uses both. You can also add the attribute by hand:
<script defer src="https://cloud.umami.is/script.js" data-website-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" data-domains="example.com,www.example.com"></script>How to check that you are excluded
- Methods 3 and 4: while logged in, view the page source and search for
data-website-id. It should not be there. In a private window it should be. - The browser flag: the script stays on the page, but no request ending in
/api/sendgoes out when you reload. - Any method: click around your site while watching Realtime in Umami. Nothing should appear.
These methods only stop new visits from being recorded. Visits Umami has already counted stay in your stats. If something does not behave as expected, see the troubleshooting guide.
Frequently asked questions
How do I stop Umami from tracking my own visits?
Open your website, open the browser console and run localStorage.setItem('umami.disabled', 1);. Umami stops counting that browser on that site until you run localStorage.removeItem('umami.disabled');. On WordPress you can also leave the script out for logged-in administrators.
Can Umami exclude my IP address?
Self-hosted Umami can. Set the IGNORE_IP environment variable to a comma-separated list of IP addresses and CIDR ranges, then restart Umami. On Umami Cloud, use the browser flag instead.
Does the umami.disabled flag work with Umami Cloud?
Yes. The flag is stored in your browser and read by the Umami tracking script on your site, so it works the same with Umami Cloud and self-hosted Umami.
Why is Umami still counting my visits on WordPress?
Either you are not logged in as an administrator in that browser, your account has another role such as editor, the browser flag is not set on that device, or the tracking code is also added a second way that has no exclusion.
Does Connect for Umami track editors and other logged-in users?
Yes. "Exclude logged-in admins" only leaves out administrators. Editors, authors, subscribers and customers are tracked. Developers can skip more roles with the cfumami_should_track filter.
How do I keep my staging site out of Umami?
Limit the tracker to your live hostnames with Umami's data-domains attribute, for example data-domains="example.com,www.example.com". In Connect for Umami, that is the Domains field under Advanced tracking.
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.