How to disable tracking of developer and admin team actions in google analytics

We have created multiple web properties and profiles. set them up using

Tried a few things to disable developer team and admin staff actions, like:

Is there a way to stop Google Analytics counting development work as hits?

I see this Disable Google Analytics when in development but it's pretty old

We need this in the staging as well as the production application apps too. And we don't want to depend on user being logged in to know if he/she is a dev or admin, we want to have a unique hidden (from listing/menu) page where if a dev or admin goes, a cookie is set which prevents tracking till the user clears cookies.


The general best practice here is to have gaoptout installed across anyone internally.

Other than that you can setup a regex to exclude internal traffic by IP and/or set a permanent cookie in your employee section and check for it before firing.

 * Required jQuery and jQuery.cookie

// login-landing-page.html
$.cookie('employee', 'true', { expires: 365 * 24 * 60 * 60 * 1000 }); // expires in 1 year

// all other pages
if (!$.cookie('employee')) { // if not employee
    // _ga.push(['_setAccount _trackpageview']) etc...

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...


if ("" ||"") {
   if (document.cookie.indexOf("COOKIENAME=COOKIEVALUE") === -1) {
      // Insert Analytics Code Here


if ($_SERVER['HTTP_HOST']==="" || $_SERVER['HTTP_HOST']==="") {
      // Insert Analytics Code Here

Verifying that the HOST name equals the domain of your live app ("") ensures that the analytics data will never be sent by ANY visitor while viewing from a test domain such as "localhost" or "". In the examples above, "" and "" 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...

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.

Need Your Help

Laravel 3 and MYSQL memory limit

php mysql laravel-3 memory-limit

I have a problem with a query that I have in Laravel 3.