Use cookies, but not how you think...
The "opt-out" add-on either hides your visits from ALL sites or doesn't work at all depending on who you ask.
Instead, keep a "developer cookie" set on your machines at all times for the domains that you manage. Set this cookie to have a unique value that is specific to your organization. Then, simply check for this cookie before sending any data to Analytics.
Examples of how to put the code into your pages...
JavaScript
if (window.location.host==="mydomain.com" || window.location.host==="www.mydomain.com") {
if (document.cookie.indexOf("COOKIENAME=COOKIEVALUE") === -1) {
// Insert Analytics Code Here
}
}
PHP
if ($_SERVER['HTTP_HOST']==="mydomain.com" || $_SERVER['HTTP_HOST']==="www.mydomain.com") {
if (@$_COOKIE["COOKIENAME"] !== "COOKIEVALUE") {
// Insert Analytics Code Here
}
}
Verifying that the HOST name equals the domain of your live app ("mydomain.com") ensures that the analytics data will never be sent by ANY visitor while viewing from a test domain such as "localhost" or "beta.mydomain.com". In the examples above, "www.mydomain.com" and "mydomain.com" are the two valid domains where we DO want visits to be recorded.
The live site sends data to analytics as expected UNLESS a developer cookie is found with matching values. If it finds that unique cookie set on your device, then your visit will not count towards the totals in Google Analytics (or whatever other analytics tool you might one day decide to use).
This method can easily be used by a team of people as long as they all use the same NAME/VALUE pair, so developers, content creators, proofreaders, and anyone else in your organization can all view pages without inflating the statistics.
To set the "developer cookie"...
Yes, you could visit a hidden page to set the cookie and give it a really long expiration date. But, clearing cookies can be a problem here, and they're invisible so you might not even be aware that they stopped working.
Or, you could use this Browser Extension to keep them set automatically...
https://chrome.google.com/webstore/detail/lknhpplgahpbindnnocglcjonpahfikn
Full disclosure: I created this extension. I was facing the same problem as you and couldn't find a solution, so I made my own. It uses a visible green icon to illustrate whether the cookie is on or off for the current domain so I think it is easier for less tech-savvy team members and just helps everyone to remember to use it. Just click it once for that domain and you're good to go.