• Home
  • Google Analytics
    • Customizations
    • For Ecommerce
  • Speaking
  • About
    • About Me
    • Contact Me
    • Disclaimer and Privacy Policy

Analytics Talk

Digital Analytics for Business

You are here: Home / Tips / Count Me Out: GA.JS Version

Count Me Out: GA.JS Version

Posted: April 16, 2009 30 Comments

A while back I wrote a post called Count Me Out! that explained how to exclude Google Analytics data based on the custom segment value.

My previous post was based on the old, urchin.js tracking code, and a lot of people have been waiting for an update. It’s taken a while, but here it is.

I will mention that my favorite way to exclude traffic from Google Analytics is using an IP exclude filter. An IP based exclude filter is very accurate unless you having a changing IP. The method below works best if you have a dynamic or changing IP address.

Even if you’re not interested in this post, there is a fun ‘group activity’ below. Please try it!

The old version of this hack method required you to add a new page to your website. That page would set the GA custom segment cookie (named __utmv) on your computer.

This technique works fine, but who wants to add a new page to their site? It can be a pain.

I’ve simplified this technique by removing that page. You can enter the JavaScript directly into your browser.

Step 1: Set Custom Segment Cookie

Go to the site that you are tracking with Google Analytics and view a page.

Copy the code below and paste it into the location bar of your browser and click ‘enter’ on your keyboard.

You should see a message that says, “Custom segment has been set. Time to create a filter.”

Here’s a tip, you can bookmark this JS to make it easy to reset the cookie in the future. I set the cookie every time I fire up my browser.

Step 2: Create Exclude Filter

Next, create an exclude filter in Google Analytics to exclude the user defined segment (i.e. the cookie) you just created:

This filter will exclude anyone with a custom segment cookie with a value of ‘remove-me’.

Remember, cookies are specific to a browser and computer. If you use mulitple browsers or multiple computers you need to set the cookie using all the browsers on all the computers you use.

Having Some Fun With This!

You’ve probbaly figured out that you can set the custom segment cookie on anyone’s website as long as they’re using GA. This means that you can add data to their User Defined report. Let’s try this on my site!

Navigate to www.cutroni.com/blog and place the following code in the location bar of your browser after the page has loaded. Change FOO to whatever you want and press enter on your keyword. That’s it. You’re now in my data.

I’ll post some of the more popular and creative values in Twitter and maybe here at a later date.

Please try to keep it clean. I often review data with my 4 year old son :)

Thoughts on the Old Method

The old version of this technique uses a form to set the custom segment cookie which is pretty handy if you have a lot of people in remote locations that need to be excluded from the data. Just send all your coworkers, contractors, etc. a link to the page and ask them to set the cookie on their computer. It’s a little easier than asking them to paste JS into their browser.

If you’re interested in using this technique here is a new version of the page and the process.

Step 1: Create a new page on your site using the code below.

** Note ** The information below is in an iFrame. If you receive this post via email you may not see the contents.

Step 2: Go to the new page you just added, fill out the form, and click the ‘Create Cookie’ button. Keep track of the value you enter into the form, you need it for step 3.

Step 3: Finally, create an exclude filter in Google Analytics to exclude the value that you entered into the form. Remember, you need to use a regular expression for the filter field. So if you entered ‘remove-me’ in the form, enter ‘remove-me’ as the Filter Field.

That’s it. Sorry for the lame post, but I’m trying to update a lot of the old code and posts on the site.

Filed Under: Tips, Tracking Tagged With: google-analytics, Tips, Tracking

Comments

  1. John says

    April 16, 2009 at 2:51 pm

    Or just go to the link:

    http://www.epikone.com/?utm_campaign=john_is_cool&utm_source=justin_drools&utm_medium=neenerneener

    ;)

    Reply
  2. Justin Cutroni says

    April 16, 2009 at 2:57 pm

    Ha! Thanks John. I was going to mention using campaign tracking to exclude traffic, but I just wanted to keep this post about the custom segment hack.

    I’ll look for your wonderful message soon!

    Reply
  3. Marco Cilia says

    April 17, 2009 at 3:21 am

    I think you missed an escape in the experiment :D
    It should be

    I\’ll post results…

    in the alert

    Reply
  4. Justin Cutroni says

    April 17, 2009 at 6:24 am

    Thanks to those that pointed out a small error in the “experiment.” It’s been fixed.

    Justin

    Reply
  5. Rajeev Edmonds says

    April 17, 2009 at 7:30 am

    I’m glad I subscribed to your blog. I wanted this solution for long, but couldn’t find any. Thanks a ton for sharing.

    Reply
  6. Christian Watson says

    April 17, 2009 at 7:35 am

    I noticed that the JS sets the variable ‘exclude-me’ but the filter pattern in the example is ‘remove-me’.

    You might want to make them match so that people who blindly follow your example (like me) don’t set it up incorrectly!

    Reply
    • Justin Cutroni says

      April 17, 2009 at 7:40 am

      Thanks Christian for catching that! I’ve updated the code to match the screen shot. I appreciate it.

      Justin

      Reply
  7. krishna says

    April 17, 2009 at 8:12 am

    Just read the post. Need a small inquiry here. The cookies code seems to be working only on Firefox browsers isn’t it?..how abt other browsers like IE, Opera, Chrome..Seems not working there

    Reply
    • Justin Cutroni says

      April 17, 2009 at 8:27 am

      Krishna,

      This should work with IE6, IE7, FF and Chrome. Did not test in Opera, but I should.

      Are you having trouble with Chrome?

      Justin

      Reply
  8. krishna says

    April 17, 2009 at 8:30 am

    Justin,

    Yes i am having trouble while working with Chrome here

    Reply
    • Justin Cutroni says

      April 17, 2009 at 8:36 am

      I just ran another test on Chrome 1.0.154.53 and I am seeing the JS message and the cookie. Are you on a developer version? One other thing to check is make sure you are on a site that is running GA. I often forget to do that :)

      Reply
  9. krishna says

    April 17, 2009 at 8:41 am

    Huhh it worked now .. its a stupid mistake i made here..I’m not on a site that is running GA.

    Many Thanks Justin for being so patient in replying to me

    Cheers !

    Reply
  10. FMK says

    April 17, 2009 at 10:41 am

    I’ve had problems with using _setVar() where it causes unwanted visits to be counted in profiles. For instance, if I have a profile including only traffic to one subdomain, visits will show up from other subdomains although pageviews do not. This leads to weird looking reports where there are thousands of visits and 0 pageviews. This problem only appears when _setVar() is used. It also appears to be responsible for changing the hostname to (not set). I’ve searched for solutions and played with different combinations of filters and the only solution I’ve found is to never use google’s _setVar() function. Some others have written their own javascript functions to set the _utmv cookie without the side effects. That seems workable although I haven’t tried that out yet. Could you post something about using _setVar(), what it actually does (vs what it’s documented to do) and how we should work with it? Thanks.

    Reply
  11. Adrian says

    April 17, 2009 at 12:31 pm

    Justin,
    Instead of creating a filter, could I just do an advanced segment?

    Reply
    • Justin Cutroni says

      April 17, 2009 at 10:24 pm

      Adrian,

      Absolutely, you could use an advanced filter. But GA will sample your site data if there are more than 200k visits in the date range you’re looking at. And this can cause some weird data given the small volume of traffic from the custom segment.

      Thanks for the suggestions and thanks for reading the blog.

      Justin

      Reply
  12. Nick says

    April 30, 2009 at 12:12 am

    Nice article Justin,

    Your bookmarklet approach is very clean and easy.

    -Nick

    Reply
  13. Geoff says

    May 15, 2009 at 11:55 am

    Hi Justin, I’m setting up some tracking using GA and am having a problem that hopefully you can help with. I think your book will be very helpful to me for e-commerce and I plan to use that at that time.

    The problem is this. When the user arrives from a banner at the site, the entire UTM string shows in the address bar like this:

    http://www.mydomain.com/somepage.html?utm_source=VAR1&utm_medium=VERT&utm_content=AD1&utm_campaign=CAM1

    whereas all I’d like them to see in the browser is http://www.mydomain.com/somepage.html as I’ve noticed happens when other sites I go to using GA show despite the link showing the whole string. I tried a mod_rewrite i.e. (rewritecond and rewriterule) and can strip all the ?utm… string off, but then nothing is collected by GA.

    I thought there must be something I need to fix in the GA script but can’t figure it out. Apart from this, the GA seems to be working fine.

    Any help is much appreciated.
    Thanks

    -Geoff

    Reply
    • Justin Cutroni says

      May 18, 2009 at 4:16 pm

      Geoff,

      You’re not doing anything wrong. In order for GA to collect the data you need to see the campaign parameters in the URL of the page. If the parameters are not there then the JS won’t be able to identify where the visitor came from. Sorry for the bad news!

      Thanks for the question,

      Justin

      Reply
  14. Ken says

    May 23, 2009 at 12:54 pm

    Hi Justin,
    I got your GA book… Great stuff! I learned (and am continuing to) learn alot!

    I have a question about setting the Custom Segment Cookie/ Exclude Filter.

    Do you have an idea about how stable the cookie is?

    When I set up a client’s WordPress website with GA and want to exclude them (and me too!) using this method, how often should they reset the cookie? You mention that you set it every time you fire up your browser. That’s an onerous task to ask my clients to do.

    Do you know of a way to automatically reset the cookie periodically?

    Thanks!
    Ken

    Reply
    • Justin Cutroni says

      May 30, 2009 at 7:17 pm

      Hi Ken,

      Glad you like the PDF. Look for a new version this summer.

      Re: your question, the cookie will last 6 mo as long as it is not erased. if you’re using WP you could reset the cookie set every time the user logs in. That will give you a reliable way to keep it on the user’s machine.

      Thanks for reading the blog and thanks for the question.

      Justin

      ps – if you want to send the cookie value by email you’ll need to make that tweak, I’m busy updating/writing books :)

      Reply
  15. Ken says

    May 28, 2009 at 12:58 pm

    Hi Justin,
    As a followup to my previous question… I’m not super great at getting forms to do “unusual” things. Would it be possible to have your “Count Me Out” form set the cookie *and* have the value sent to me via email on the same click?

    That way I could have a client set the cookie on their computer and also inform me of what I need to exclude in their Analytics…

    Thanks!
    Ken

    Reply
  16. Daniel Marashlian says

    May 30, 2009 at 2:32 pm

    Justin,

    Thanks so much for the tip! This will be SUPER helpful for everyone over here on the Pelotonics team. It makes sense to just create a bookmark since a lot of us are clearing our cookies everyday.

    Cheers mate!
    Daniel

    Reply
  17. Sonia R. says

    April 29, 2010 at 5:01 am

    Hello!
    I know this post is a bit old and all but I would just like to ask a small question! This code doesn’t seem to work in IE8, it just doesn’t create any cookie, it should work right? It works in Firefox and Chrome. Could you please tell me if it works with you or it’s just me? Thank you.

    Reply
    • Justin Cutroni says

      May 3, 2010 at 11:21 pm

      @Sonia;

      I have not tried it in IE8, in fact, I haven’t used IE in a couple of years :) But yes, you are correct, it should set a cookie. I’ll see if I can debug it soon. But, to be honest, the User Defined feature will be deprecated in the future and we should use Custom Variables.

      Reply

Trackbacks

  1. Filtering Dynamic Ip Addresses From Google Analytics says:
    May 4, 2009 at 10:17 am

    […] Nice post over at epikone.com on filtering out dynamic ip addresses from google analytics: http://www.epikone.com/blog/2009/04/16/count-me-out-gajs-version/ […]

    Reply
  2. Excluye direcciones IP dinámicas en Google Analytics | diarioTHC, recursos para webmasters, bloggers y diseñadores says:
    May 20, 2009 at 7:29 pm

    […] Talk Blog y podrás acceder a la explicación de como ponerlo en práctica, por medio de éste enlace. Siempre será bueno saber que hay personas que han encontrado soluciones fiables para […]

    Reply
  3. Don’t Count Me!: Google Analytics and WordPress « Jeb Stone > Analytics says:
    October 12, 2009 at 10:14 pm

    […] EpikOne has a great post on how to exclude yourself from Google Analytics, and with a very slight modification you can create an admin page in WordPress that provides a one-click solution no matter where you’re editing from. […]

    Reply
  4. Exclude dynamic IP traffic from Google Analytics | Blogburger says:
    November 25, 2009 at 11:50 am

    […] on the Analytics Talk blog they’ve come up with another way to do this which replaces the special web page with a snippet of code that you paste into your address […]

    Reply
  5. Google Analytics – Como no contabilizar sus propias visitas de las estadísticas | Blaunia – Noticias de TI says:
    September 5, 2010 at 4:04 pm

    […] no tuve respuesta, rebuscando por Google he encontrado la respuesta en el blog de Justin Cutroni, http://cutroni.wpengine.com/2009/04/16/count-me-out-gajs-version/. Para los que no sean unos admiradores de la lengua de shakespeare o quieran conocer lo esencial […]

    Reply
  6. Exclude dynamic IP from google analytics - Webdesign says:
    October 30, 2010 at 11:15 pm

    […] This is just an update of the post Count me out Last year, the analytics talk blog released a post about how to exclude dynamic IP from the reports […]

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

My Books

Google Analytics by Justin Cutroni
Learn More on Amazon.com

Performance Marketing co-authored by Justin Cutroni
Learn More on Amazon.com

Recent Posts

  • Understanding the Google Analytics Cohort Report
  • Using Offline and Online data to drive Google Analytics Remarketing
  • Understanding Cross Device Measurement and the User-ID
  • Universal Analytics: Now out of beta!
  • Advanced Content Tracking with Universal Analytics

Categories

  • About Google Analytics (25)
  • Analysis (52)
  • Analytics Strategy (3)
  • Campaign Tracking (14)
  • Ecommerce (8)
  • Event Tracking (10)
  • Remarketing (2)
  • Reporting (10)
  • Resources (7)
  • Tag Management (5)
  • Tips (25)
  • Tracking (52)
  • Uncategorized (64)
  • Universal Analytics (9)
  • Web Analytics (15)

Copyright © 2023 ·News Pro Theme · Genesis Framework by StudioPress · WordPress