User Login

Help Community Login:

Can I Track IP Addresses With My Google Analytics?

34 replies [Last post]

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?
R wrote:

could you give us the java code?

I wouldn't actually recommend forcing Javascript to do this, when it's so much easier to just rename the page that you have the GA code on to a .php extension. It adds alot more code and processing than is necessary, and is much more confusing. But if you're bound and determined to not rename that file to.php, here are 2 excellent links with information on how to do it. Smile

Can Javascript know your IP?

Get Client IP using just Javascript?

Although after you check them out I have a feeling you'll agree. Wink



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

the source code provided by GA is this

<script type="text/javascript">
 
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-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.insertBefore(ga, s);
})();
</script>

I simply copied and pasted in my .html pages without changing anything and keeping the extension as .html.
Then I added the line to set a custom variable and it was not working because, you said, it is a PHP code but I am confused because it seems to me that they are using the same language...
Anyway, I tried to save all my pages as .php but I surely missed something because it did not work (i.e. tha pages did not upload coorectly). I probably re-try and take a look to the links you sent me

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?

The part where it says <?php ... ?> tells the browser that your page has some PHP code in it (the part between those two 'tags'), which is why you need to rename it from .html to .php.

How are you uploading the pages to your server, with an FTP program? You may need to set it's upload mode to "Auto" before uploading the files if it's not already (usually is by default).

I whipped up a test page using your GA ID number and pasted exactly what I had on the first page, I just added your GA ID. Grab it here, and upload it to your server, then just navigate to: http://your-site.com/ga-test.php. View the source code to it and see if you spot an IP address in the code, if you do it's working. Also, read the short instructions I put on it. Lemme know how it turns out. 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?

Hi

I upload the page as .php and when I opne the source code I actually spot an IP adress. However, when I go to

http://your-site.com/ga-test.php
it says 'sorry but the page does not exist' and the IP still does not appear on GA.
I do not know if I am doing everything right...

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?
R wrote:

However, when I go to

http://your-site.com/ga-test.php
it says 'sorry but the page does not exist'

Might seem like a stupid question, but are you replacing "your-site.com" in that URL with your own actual site name? If you just go to the exact URL I gave you'd get a page doesn't exist error.



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?

Sorry, when I go to the page you suggest it's actually showing the text you put on it...
but still no IP on GA Sad(((

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?

When you load up the page and see that text I put, view the page's source code and look for an IP address in the Google Analytics code, if it shows, it's working. Also, be sure to give it at least 24 hours since going to the page. GA is kinda slow with that.



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?

Now the IP is appearing!
however, these IP adresses are the ones that have visited the page saved as .php?
I will try to re-upload all the pages as .php, but I don't understand why the last time my server was not able to correctly upload the pages...I just have to change the extension of pages and and the other files saved normally as .html, is it right? such as index.html? and also sitemap.xml and feed.xml?

thanks a lot!
rachele

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?
Rachele wrote:

I just have to change the extension of pages and and the other files saved normally as .html, is it right? such as index.html? and also sitemap.xml and feed.xml?

Yep, just changing the file extensions to .php will do the trick. Only for the .htm/.html files though, not .xml. XML files are basically just a flat database file and javascript/php don't work within them.

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

I still have a further question
in the test page you uploaded for me you wrote
['_setCustomVar', 1, 'IP', "(Mod note: IP Removed)", 2]

instead of

_gaq.push(['_setCustomVar', 1, 'IP', "<?php echo $_SERVER['REMOTE_ADDR']; ?>", 2]);

should I then replace what you wrote in all my pages or can I use the original line code? your line is associated to a specific IP...

Who's New

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
EmilyRose's picture
golith's picture
facebook codes exploits tips tricks Phrozen Crew
All contents ©Copyright GeekDrop 2009-2017
TOS | Privacy Policy