Restrict Tracking to Specific Domains

How can I restrict tracking of a site to a specific domain?

I’m a web developer and when I am testing a site locally using http://localhost Piwik still tracks my page views. I want Piwik to only track page views if they are coming from a specific domain.

I’ve searched through the settings and the forum for how to change this, but I can’t seem to find one.

This is a feature request: New website setting: Only track visits and actions when the action URL starts with one of the above URLs · Issue #588 · matomo-org/matomo · GitHub

You can do it in javascript otherwise, eg.

if(document.domain == ‘xxxxx’) {

// piwik code here
}