User Login

Help Community Login:

Can I Track IP Addresses With My Google Analytics?

34 replies [Last post]
Badgerark's picture
Badgerark
Joined: 06/03/2009
Posts: 2
Drops: 4
Mood: Weird

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
STaRDoGG's picture
From:
Olympus
STaRDoGG
Head Mucky MuckJoined the Dark SidePremium Member (Gold)I'm a Code Monkey!The Steel CurtainI use FirefoxI use Google ChromeI use Internet ExplorerI use SafariLinux UserMac UserWindows UserI donated to GeekDrop simply because I love it!Booga Booga BoogaI took a bite of the AppleFormer Phrozen Crew MemberI'm MagicMember of VileThe Dr. put the stem on the apple!The JokerSomeone thinks you're udderly delightful!
Relationship Status:
Divorced
Joined: 01/14/2009
Posts: 2549
Drops: 2998
Mood: Curious
Re: Can I Track IP Addresses With My Google Analytics?
Badgerark wrote:

I'm using Google Analytics on my blog but can't find any reports in my stats showing my visitor's IP's anywhere, is there some way to view them?

Sure is Wink But I have to throw out the usual disclaimer first: Google considers it an invasion of privacy to see your visitor's IP Addresses. Personally speaking, I don't (much). Webmasters have long been able to view their visitors IP's in their server web logs, 3rd party visitor trackers, and even in most CMS's that they may have installed. ("CMS" for those that may not already know stands for "Content Management System". In other words, those pre-made websites that tens, or even hundreds of thousands of people use, for example, Wordpress, Drupal, Joomla, PHPNuke, and many Forum softwares), although if you're on some free Hosting service, like Blogger or Wordpress.com you may not have natural access to visitor IP addresses.

Sure, if you have someone's IP Address you can get some basic info, like the town/state they may live in and stuff like that, but to get any real personal info out of it you'd need court orders and stuff like that, and if it's come down to that, it's probably a good thing that you have their IP address, maybe the person behind it has been harassing you or some visitor(s) of your site. That said, it's the Big G's policy, so do the following trick at your own risk, there's the potential to lose your Google Analytics account.

On with the Shew

Just paste the following code in place of the code Google Analytics gives you, or if you know what you're doing, use the relevant parts in your own code.

<script type="text/javascript" defer="defer">
  var _gaq = _gaq || [];
	_gaq.push(
	  ['_setAccount', 'UA-XXXXXXX-X'],
	  ['_setCustomVar', 1, 'IP', "<?php echo $_SERVER['REMOTE_ADDR']; ?>", 2],
	  ['_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.insertBefore(ga, s);
  })();
</script>

This is basically your standard, run of the mill code you're given by Google Analytics to add to your website page(s), with the exception of the "setCustomVar" line. What this does is creates a custom variable to track for each visit / page load, etc. named "IP" (You can name it whatever you want if you don't like "IP"), and then using PHP echoes the visitors IP address right into the source code which is sent back to Google Analytics along with the rest of the usual visitor information. I've used PHP in this example because it's arguably the most commonly used. If you need a javascript version, just ask and I'll add it as well. Smile

A little extra info:

  • The "defer" part of the first line isn't necessary. I personally like adding it to some of my javascript because it saves loading it all up until the page has finished loading, which can visually speed up page loading to visitors. Otherwise it loads it all as it's called in the page from top to bottom.
  • Some webmasters / coders/ Google-Analytics-itself will use separate lines when adding the variables to track to the gaq.push array. I tend to prefer adding them all at once like I did in the code above. I just think it's slightly neater, easier to follow, and may have a very slight speed increase, but this is arguable, so do whichever you prefer, if you know what you're doing, if not just use my code, it works great.
  • Obviously you'll need to replace the X's on the "setAccount" line with your own Google Analytics personal account code.

After that you can view IP Addresses by drilling down in your "Custom Variables" area.

And finally, everyone loves screenshots ...

how to show visitor ip addresses google analytics
 

how to show visitor ip addresses google analytics



Shhh.. dont tell anyone, but we also have a private forum area with the really good stuff, see?

u.danse's picture
u.danse
I use Internet ExplorerWindows User
Relationship Status:
Single & Not Looking
Joined: 08/06/2012
Posts: 2
Drops: 2
Re: Can I Track IP Addresses With My Google Analytics?

hi

I want to try this.

Please tell me the version of javascript !!

I've tried with this

it didn't work and i can't find IP menu in custom variable.

Did not make it.

Please let me know!!!

STaRDoGG's picture
From:
Olympus
STaRDoGG
Head Mucky MuckJoined the Dark SidePremium Member (Gold)I'm a Code Monkey!The Steel CurtainI use FirefoxI use Google ChromeI use Internet ExplorerI use SafariLinux UserMac UserWindows UserI donated to GeekDrop simply because I love it!Booga Booga BoogaI took a bite of the AppleFormer Phrozen Crew MemberI'm MagicMember of VileThe Dr. put the stem on the apple!The JokerSomeone thinks you're udderly delightful!
Relationship Status:
Divorced
Joined: 01/14/2009
Posts: 2549
Drops: 2998
Mood: Curious
Re: Can I Track IP Addresses With My Google Analytics?

Welcome to GD u.danse Smile

Google Analytics usually takes ~24 hours before showing some info so that may be why it wasn't showing right after you added it and tested. Is it still not showing? I don't believe javascript version should be a factor in this situation.



Shhh.. dont tell anyone, but we also have a private forum area with the really good stuff, see?

u.danse's picture
u.danse
I use Internet ExplorerWindows User
Relationship Status:
Single & Not Looking
Joined: 08/06/2012
Posts: 2
Drops: 2
Re: Can I Track IP Addresses With My Google Analytics?

so thank you STaRDoGG !!

it's working now!!

but i have a problem ..

almost all IP displays like this --><?php echo $_SERVER['REMOTE_ADDR']; ?>

and only few IP displays to nunber.

do you know why?

PLEASE HELP ME ...!!!!

STaRDoGG's picture
From:
Olympus
STaRDoGG
Head Mucky MuckJoined the Dark SidePremium Member (Gold)I'm a Code Monkey!The Steel CurtainI use FirefoxI use Google ChromeI use Internet ExplorerI use SafariLinux UserMac UserWindows UserI donated to GeekDrop simply because I love it!Booga Booga BoogaI took a bite of the AppleFormer Phrozen Crew MemberI'm MagicMember of VileThe Dr. put the stem on the apple!The JokerSomeone thinks you're udderly delightful!
Relationship Status:
Divorced
Joined: 01/14/2009
Posts: 2549
Drops: 2998
Mood: Curious
Re: Can I Track IP Addresses With My Google Analytics?

It sounds like you may not have your page/file that you placed the code on saved as .php? (i.e. if it's on your index.htm page you should rename it to index.php). If that's not it then I'm wondering if you have PHP installed on your web server, because what's happening is the actual PHP code isn't being executed, only placed literally in that Google Adsense variable.



Shhh.. dont tell anyone, but we also have a private forum area with the really good stuff, see?

bioepostdoc's picture
bioepostdoc
Re: Can I Track IP Addresses With My Google Analytics?

Hi all

I tried to implement the code you suggested in your post (more than 24h ago...) and unfortunately nothing happens, I can't see the IP in the Custom Variables menu...

any hints?

thank you
R

STaRDoGG's picture
From:
Olympus
STaRDoGG
Head Mucky MuckJoined the Dark SidePremium Member (Gold)I'm a Code Monkey!The Steel CurtainI use FirefoxI use Google ChromeI use Internet ExplorerI use SafariLinux UserMac UserWindows UserI donated to GeekDrop simply because I love it!Booga Booga BoogaI took a bite of the AppleFormer Phrozen Crew MemberI'm MagicMember of VileThe Dr. put the stem on the apple!The JokerSomeone thinks you're udderly delightful!
Relationship Status:
Divorced
Joined: 01/14/2009
Posts: 2549
Drops: 2998
Mood: Curious
Re: Can I Track IP Addresses With My Google Analytics?

Thinking If you've followed all the directions to a T, double-checked for any errors in the code (typo's etc.) and made sure your page is saved as .php, and PHP is running fine on your server, I'm not really sure. How much traffic does the page that you're testing it on get? There's a chance that you and/or the visitors may have some ad blocking software installed that is blocking the Google Analytics code as well, which is somewhat common.

bioepostdoc's picture
bioepostdoc
Re: Can I Track IP Addresses With My Google Analytics?

Hi,

when I simply copied the code provided by Google Analytics, I did not have to save the page as .php; why should I do that now? Anyway, I do not know if the server I am using for my website supports this kind of files...is there any other solution then? Wink
thanks a lot!
R

STaRDoGG's picture
From:
Olympus
STaRDoGG
Head Mucky MuckJoined the Dark SidePremium Member (Gold)I'm a Code Monkey!The Steel CurtainI use FirefoxI use Google ChromeI use Internet ExplorerI use SafariLinux UserMac UserWindows UserI donated to GeekDrop simply because I love it!Booga Booga BoogaI took a bite of the AppleFormer Phrozen Crew MemberI'm MagicMember of VileThe Dr. put the stem on the apple!The JokerSomeone thinks you're udderly delightful!
Relationship Status:
Divorced
Joined: 01/14/2009
Posts: 2549
Drops: 2998
Mood: Curious
Re: Can I Track IP Addresses With My Google Analytics?
Guest wrote:

when I simply copied the code provided by Google Analytics, I did not have to save the page as .php; why should I do that now? Anyway, I do not know if the server I am using for my website supports this kind of files

The code that Google gives is Javascript, which is a language than all browsers understand by default. The code I provided in order to add the IP tracking is a different language (PHP). Browsers understand that too, but in order for the page itself to know how to handle the PHP code it just needs to be renamed from .html/.htm to .php. You'll see absolutely no difference in anything else by renaming it. Almost all servers these days support PHP, so chances are it'll work just fine. Give it a try, you've got nothing to lose. Smile



Shhh.. dont tell anyone, but we also have a private forum area with the really good stuff, see?

bioepostdoc's picture
bioepostdoc
Re: Can I Track IP Addresses With My Google Analytics?

re-hi! Wink

I'll try then, but as you said could you give us the java code?
thanks!
R

Who's New

lovely's picture
StephenKreppel's picture
askomonev's picture
Haroom Khan's picture
dnayaroland's picture
hosecansu's picture
princessbell68's picture
_decoded's picture
jenandrews1975's picture
rollupbanner's picture
molbari's picture
Iliqnze123's picture
koste1's picture
pamjblack's picture
mongeau's picture
facebook codes exploits tips tricks Phrozen Crew
All contents ©Copyright GeekDrop 2009-2017
TOS | Privacy Policy