User Login

Help Community Login:
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:
Married
Joined: 01/14/2009
Posts: 2476
Drops: 2903
Mood: Chipper
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?

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <embed> <object> <strike> <caption> <thead> <th> <param> <style> <BGSOUND> <color> <center> <font-size> <script>
  • You may quote other posts using [quote] tags.
  • Filtered words will be replaced with the filtered version of the word.
  • Textual smileys will be replaced with graphical ones.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <csharp>, <css>, <html4strict>, <javascript>, <php>, <vb>, <vbnet>, <xml>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Lines and paragraphs break automatically.

More information about formatting options



NOT LOGGED IN

You are NOT logged in

NOTE: You are commenting as an anonymous guest. Anonymous comments are held in a queue for moderation before they're made public, also all links are set with a NO FOLLOW flag. If you'd like your comment to be public immediately, please login or create an account (no worries, it's free).


Who's New

carolainekerollyn's picture
iqbal's picture
gitanjali_singh@yahoo.com's picture
socaldrummer's picture
panchal's picture
manoelnano's picture
annabiagioni's picture
sabri's picture
pmton's picture
MADUSANKA NUWAN KUMARA's picture
keumkeochantavongsa's picture
sxymomma2013's picture
camero66's picture
Finn9595's picture
Youngestengineer's picture
facebook codes exploits tips tricks Phrozen Crew
All contents ©Copyright GeekDrop 2009-2013
TOS | Privacy Policy