Google Analytics IP Address Tracking Script with PHP

Google Analytics is by far the most widely used web analytics software, free or enterprise level, but it has several downsides, including lack of IP address tracking. You are able to drill down to the Service Provider names but that does not provide enough detailed data, especially if there are several users that use the same ISP but are in no other way related to each other, which can be a problem when analyzing traffic data.

Google Analytics obviously uses IP address tracking in their system but they choose not to reveal that data to its users for privacy reasons. This really does not make much sense to me since nearly every other web analytics tool allows you to track IP addresses. But luckily there may be a way around that by adding custom tracking variables with PHP (although it may be against Google Analytics TOS, which I am not really sure what will happen if you break the TOS).

So, here is how you can do track IP addresses in Google Analytics with this PHP and JavaScript script:

“javascript:__utmSetVar(‘php echo IP address function’)”>

Now you will be able to look up IP addresses in the User Defined field of the Visitors tab in the Google Analytics dashboard.

Comments

One Response to “Google Analytics IP Address Tracking Script with PHP”

  1. RickyH on May 13th, 2011 11:59 am

    So where does the snippet go? If in the GA tracking code, where would one put it? Some examples of the new asynch and traditional code would be nice.

    Thanks.

Leave a Reply