Path Exclusions
Use excludePaths to skip pageviews for matching paths.
Configuration
Pass an array of bare regex patterns (strings, not regex literals):
{
domain: 'your-site.com',
excludePaths: ['^/admin', '^/staging', 'preview'],
}
The plugin compiles each pattern as a RegExp and tests it against window.location.pathname on route changes. If a pattern matches, the plugin does not send that pageview.
Pattern syntax
| Pattern | Matches |
|---|---|
^/admin | Any path starting with /admin |
^/admin$ | Exactly /admin (no sub-paths) |
preview | Any path containing the word preview |
\\.(json|xml)$ | Paths ending in .json or .xml |
Bare patterns only
Pass patterns without regex delimiters. "^/admin" is correct; "/^\/admin/" is not. The slashes become part of the pattern.
How it works
At build time, the plugin adds the patterns to the page as regular expressions:
<script>
window.plausibleExcludePaths = ["^/admin","preview"].map(function(p){ return new RegExp(p); });
</script>
On each route change, the client module checks the patterns before calling window.plausible('pageview').