开发者

Removing my local visits from Google analytics

I want my own visits to not show in Google Analytics and for this I have added a test html page on my website. The idea is that I would hit this page once and GA should not count any of my visits in the analytics(by setting the opt_scope value in the _setCustomVar to "visitor" level). Following is the code snippet of my test html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'xyz']);
    _gaq.push(['_setCustomVar', 'myvisits', 'myvisits', 1]);
    _gaq.push(['_trackPageview']);        

    (function () {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode开发者_如何学JAVA.insertBefore(ga, s);
    })();

And, now in my Analytics I have set the following settings:

Filter Name: Myvisits
Filter Type: Custom filter
             Exclude
Filter Field: User Defined
Filter pattern: myvisits
Case sensitive: No

Is there a way to verify whether my customvar is getting passed to GA. I tried to look into the request parameters to __utm.gif anf I could not see the "myvisits" variable getting passed. Here's the request details

http://www.google-analytics.com/__utm.gif?utmwv=4.8.9&utmn=485610273&utmhn=www.example.com&utmcs=ISO-8859-1&utmsr=1173x733&utmsc=24-bit&utmul=en-us&utmje=0&utmfl=10.1%20r85&utmhid=2133980375&utmr=-&utmp=%2Fplain.htm&utmac=xyz&utmcc=__utma%3D14266660.362063006.1299003679.1299003679.1299003679.1%3B%2B__utmz%3D14266660.1299003679.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B&utmu=q

Am I doing something wrong?


You forgot to add the index into your call to setCustomVar. Try:

_gaq.push(['_setCustomVar', 1, 'myvisits', 'myvisits', 1]);


I had to figure this out with my website as well. This link from google explains some ways to filter your visits. I'm not sure how good you want the filtering to work, but it seems like you can either install a cookie, or you can just have your ip address excluded. I tried to have a cookie installed that filtered my results but that didn't seem to work. Instead I decided to just go with filtering my ip since all of my visits to my site are from my home.

If you want to do it that way,

  1. Go to the overview page showing all of your sites.
  2. Click on Filter Manager.
  3. Either add a filter or edit your existing filter.
  4. Instead of clicking custom filter, click pre-defined filter and select Exclude -> traffic from the ip addressed -> that are equal to...
  5. The rest is pretty obvious.

This method has worked for me since I don't need it to be perfect, but you may be looking for a better solution.


Your script sets a CustomVar while you filter is based on UserDefinedValue. While they sound similar, they are different.

Filtering on CustomVar can be only done by defining an AdvancedSegments, not in profile filters.

Usage of UserDefinedValue is discouraged:

  • deprecated
  • sets a value for the next visit, not the current one

=> it's more reliable to filter by IP for example

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜