google-measurement-php-client icon indicating copy to clipboard operation
google-measurement-php-client copied to clipboard

Send IP address

Open coccoinomane opened this issue 7 years ago • 3 comments

Hello!

First of all, thank you for this nice tool. I prefer it over other the alternatives because it is simple and lightweight. Well done!

Now, as for the issue: would it be possible to support in GMPC the IP override parameter? I am referring to the 'uip' parameter from https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#uip.

A bit of context. I often set IP-based filters in my GA views. When I use GMPC, however, the IP sent to GA seems to be the server IP rather than the client IP.

If needed, I have written a function based on a Stack Overflow answer in order to extract the client IP; you can find the function here: https://gist.github.com/coccoinomane/4c420776dc16d80ea772aff06d3e1ef4

Thank you, Guido

coccoinomane avatar Sep 05 '16 15:09 coccoinomane

A follow up: while having the IP information sent would still be a useful feature, it appears that it would not solve the issue about IP filtering.

Apparently, IP addresses sent via the Measurement Protocol are automatically anonymized (just as if aip were used). In other words, if you send uip=1.2.3.4 it will be anonymized to 1.2.3.0 so any specific filter looking for 1.2.3.4 will fail to match (see this Google ticket).

This means that filters are bound to be inefficient as they can only act on the first three blocks of the IP address. More details in this StackOverflow answer.

I have tested this behaviour by including my ip address in an exclude-filter in GA, and by adding the following line to getTrackingPayloadData():

$payloadData['uip'] = '<my ip address>';

Even though the IP data was sent correctly, the filters in GA didn't fire.

In my humble opinion, the case for implementing this feature still stands, as sending the correct IP in anonymized form is in most cases more useful than always sending the server IP.

coccoinomane avatar Sep 05 '16 19:09 coccoinomane

Hey @coccoinomane thanks for your suggestion, i will look into this and try to give some feedback 👍

ins0 avatar Sep 05 '16 19:09 ins0

Hi ins0! I have sent a pull request that forces the tracker to send IP information as well, in anomyzed form. It works for me both locally and on a website I have on SiteGround. Please let me know if you need any clarifications :-) Cheers, Guido

coccoinomane avatar May 09 '17 16:05 coccoinomane