Mobile app version of vmapp.org
Login or Join
Eichhorn148

: Is there any way to get data from Google Analytics Per Page Visit I am using Google Analytics to track visitors of my website. I also want to track IP address of the visitor but Google doesn't

@Eichhorn148

Posted in: #Google #GoogleAnalytics #Javascript

I am using Google Analytics to track visitors of my website. I also want to track IP address of the visitor but Google doesn't allow this. Now I am thinking that I must save IP address of the visitor on my database before sending visit information to Google Analytics. So when I retrieve information I can glue the IP address with visit information.

But when I query to Google Analytics using following code:

$optParams = array(
'dimensions' => 'ga:browser,ga:fullReferrer,ga:source,ga:keyword,ga:campaign,ga:customVarValue1,ga:customVarValue2'
);
return $analytics->data_ga->get(
'ga:' . $profileId, '2013-07-16', '2013-07-20', 'ga:visits',$optParams);


It is returning data like this:

[rows] => Array
(
[0] => Array
(
[0] => Chrome
[1] => (direct)
[2] => (direct)
[3] => (not set)
[4] => (not set)
[5] => 1366
[6] => 667
[7] => 2
)

[1] => Array
(
[0] => Firefox
[1] => (direct)
[2] => (direct)
[3] => (not set)
[4] => (not set)
[5] => 1366
[6] => 596
[7] => 1
)

[2] => Array
(
[0] => Internet Explorer
[1] => (direct)
[2] => (direct)
[3] => (not set)
[4] => (not set)
[5] => 1366
[6] => 673
[7] => 1
)

)


It is returning data with respect to browser vise. I want data returned with respect to visit vise means every index of row object should be with respect to each visit so that I can make my ip information saved on my local and visit information returned by Google together in report. Is there any way to do it?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Eichhorn148

2 Comments

Sorted by latest first Latest Oldest Best

 

@Cooney921

Hypothetically it would be possible to set a unique identifier in your database where you are storing your IP addresses and then use the same id as a custom variable in analytics. You would set this up as follows and call this function before the _gaq.push(['_trackPageview']); function is called:


_gaq.push(['_setCustomVar', 1, 'ID', 'SET_YOUR_UNIQUE_ID_HERE', 1])


in this example I have chosen to set the variable on a user level, you could change the last value from 1 to 2 so that this is set on a session basis. I believe there may also be limitations in how many unique values can be set and I seem to think this is 50,000.

To query this data you would have to filter by the ID that you have set and therefore you would likely need to use the API to do this effectively.

I would also recommend reviewing Google Analytics TOS as it says


You will not (and will not allow any third party to) use the Service to track, collect or upload any data that personally identifies an individual (such as a name, email address or billing information), or other data which can be reasonably linked to such information by Google


In my opinion this method would not contravening Google's policy as the unique id used in GA is random and the the personally identifiable data is tied together by yourself offline. However, this is a hypothetical solution and I am not a legal professional and so if you choose to implement this it is at your own risk and i do not accept liability as it is untested.

10% popularity Vote Up Vote Down


 

@Kaufman445

I don't think you can get IP address from Google Analytics, it is not shown by default and using custom variables to get the information would be against their TOS. You can however get IP addresses with your own script, in PHP you would do something like $_SERVER['REMOTE_ADDR'];

Google source stating "It is not possible to track IP addresses using Google Analytics"

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme