How can I find the IP address for my visitors in Google Analytics Universal reports?
Here are the instructions to view IP addresses in Google Analytics.
Add the following code to your pages, before the traditional Google Analytics code:
<?php
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip=$_SERVER['HTTP_CLIENT_IP'];}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];} else {
$ip=$_SERVER['REMOTE_ADDR'];}
?>
Then add this code to your webpages before </body>:
<script type='text/javascript'>
_gaq.push(['_setCustomVar', 1, 'IP', '<?=$ip;?>', 1]);
</script>
To see the data:
Create a report in "Custom Reporting".
Select Custom Variable (Value 01) as first dimension.
Select all the web metrics you want to see (visits, pageviews, time on site, etc.)
Here are the instructions to view IP addresses in Google Analytics.
Add the following code to your pages, before the traditional Google Analytics code:
<?php
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip=$_SERVER['HTTP_CLIENT_IP'];}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];} else {
$ip=$_SERVER['REMOTE_ADDR'];}
?>
Then add this code to your webpages before </body>:
<script type='text/javascript'>
_gaq.push(['_setCustomVar', 1, 'IP', '<?=$ip;?>', 1]);
</script>
To see the data:
Create a report in "Custom Reporting".
Select Custom Variable (Value 01) as first dimension.
Select all the web metrics you want to see (visits, pageviews, time on site, etc.)