Saturday, January 26, 2008

Google Analytics: Tips and Tricks - Show Visitor IP Address in a Report

Problem:
A user of web analytics yahoo group asked if there is a way to show visitors IP address in Google Analytics (GA).

Solution:
Visitors IP address is shown in one of the out of the box reports of most of the web analytics tool or can be easily configured by few clicks. That’s not the case with Google Analytics. I had not tried to create this report in Google Analytics but thought this should not be difficult considering Visitor IP was one of the options available in Google Analytics filters. But after few tries (and finally an email from Brian Clifton, head of Web Analytics at Google EMEA, confirmed that Google Analytics does not allow you to show visitor IP in any report. In fact they do not store Visitor IP because it is considered a Personally Identifiable Information (PII) and storing it in GA is against Google's Privacy Policy. If you are interested in knowing what I tried (because I thought that it will work) continue reading else you have your answer:
Google Analytics does not allow you to see Visitors IP in any report.

What I Tried:
I created a Custom Filter to grab Visitor IP and put it in “User Defined” visitor attribute. “User Defined” attribute is then shown in “User Defined” report (Figure 1 and Figure 2). This attribute can also be used to segment some other reports (Figure 3).
Figure 1


Figure 2


Figure 3


How to create “Visitor IP” Filter
  1. Click on “Edit” next to the profile for which you want to create the filter for.

  2. Click on “Add Filter” on the next screen

  3. On Next Screen

    1. Choose “Add New Filter for Profile” radio button

    2. Enter a description name for filter in “Filter Name” field e.g. “Show Visitor IP”

    3. Select “Custom” from “Filter Type” drop down

    4. Choose “Advanced” radio button

    5. Select “Visitor IP” from “Field A -> Extract A” field drop down and enter (.*) in the field next to it. What this is telling GA is to select Visitor IP and extract all of the content into a temporary variable called A.

    6. Skip the next line “Field B -> Extract B” as you don’t need any other value

    7. Select “User Defined” from “Output To -> Constructor” and enter $A1 in the next field. What this is telling GA is that take the first value from A (hence $A1) and put it into “User Defined” variable. This will then show up in “User Defined” report.

    8. Select “Field A Required” as Yes

    9. Select Field B Required” as No, since there is no Field B

    10. Select “Override Output Field” to Yes because you want the new value to replace anything that might be there (also note that “User Defined” attribute can have only one value).

    11. Select “Case Sensitive” as No

    12. Click “Finish” button (not shown in the screen above)




The above steps create the filter and will be automatically applied to the profile that you created it for.
Since GA allowed me to choose Visitor IP and create a filter my first reaction was that it should work (not knowing that GA does not store IP). I should have got a hint when I did not see any results and went back to edit my filter. The filter screen had wiped out my selection of Visitor IP in field A (see below).
I thought it was a bug but now I think GA was telling me that “It Won’t Work”. Lesson Learned. Remember what Thomas Alva Edison said” I have not failed. I've just found 10,000 ways that won't work.”

So why I am writing about Google Analytics? Well earlier this month, I wrote in my 2008 Web Analytics prediction that

Google Analytics will mature further and start taking customers from other analytics tools like Omniture, WebTrends, Clicktracks etc. The configuration will become little complicated (and hence need for Google Analytics Expertise will grow) and Google will also expose more APIs to allow companies to pull and merge different kinds of data with Web Analytics Data.

Considering, if what I predicted will indeed come true then it is time to start writing about the lessons I learn while configuring Google Analytics and share my experience so that others can learn from my success and mistakes and also share their experiences.

Have you done custom configuration in GA? Would you like to share your custom configurations? How you created them, what worked what did not etc. If yes, please send me an email and become a co-author on this blog. I will be doing a series on Google Analytics configuration and the lessons I have learned.

5 comments:

  1. Have you tried it with the setVar function? You can put someone's IP in this call:

    pageTracker._setVar("123.123.123.123");

    Or is Google also filtering those out?

    ReplyDelete
  2. _setVar does essentially the same thing; it puts the value in "user defined". _setVar would have required additional coding to grab the IP and put it in _setVa. Since “Visitor IP” variable was available I decided to give it a try. I am sure setting IP with setVar will work. But remember IP is considered PII and storing any PII will violate the Google TOS and can result in cancellation of your GA account.

    ReplyDelete
  3. Anonymous12:29 PM

    The only solution is to change your site's code manually but i dont recommend that, the best is to use GA concurrent with another web log application

    ReplyDelete
  4. Anonymous9:37 PM

    Hi Anil,

    GA considers a visitor's IP address PII and therefore blocks you from displaying it in any report. In fact, it is against the TOS to collect any personally identifiable information using GA. This includes adding PII to the custom segment value.


    Justin

    ReplyDelete
  5. Anonymous12:41 PM

    Google is just trying to act professional so people will think they are good in keeping Personal Information away from unauthorized users. In fact, they do collect everything from users for making $$$.

    ReplyDelete

I would like to hear your comments and questions.