Search code examples
phpgoogle-analyticsmeasurement-protocol

Google Analytics Measurement Protocol Event results as Realtime visitor from United States


Currently i am making a custom event that will trigger from PHP and i am using Measurement Protocol.

I had validate the event - and its "valid": true. I also see the event in Real-time reports.

When i am testing the event and when i check Analytics Real-time i have visitor not only from my country/city, but also 1 more from United States/New York.

So if i am on the site , chill`n ... i see only 1 user in real-time with the correct location (me). But when i trigger the specific event i am working on - i have one more real-time visitor from United States/New York.

??

I cant explain this to my self..

These are the request parameters:

$data['v'] = 1;
$data['tid'] = 'UA-XXXXXX-X';
$data['cid'] = '5sd5AsdSHfsd53sdfdD25SD54fgdsfg49dd854';
$data['uid'] = '100';
$data['t'] = 'event';
$data['ec'] = 'registration';
$data['ea'] = 'form';
$data['el'] = 'User Data';
$data['ev'] = 1;
$data['dh'] = 'mydomain.com';
$data['ds'] = 'web';

Someone got this problem and/or solution?

Thank you!


Solution

  • The Measurement Protocol gets its location information from the IP address of the computer making the request. If your server is hosted in the US, then that's where the hit will show as coming from.

    You can avoid this behavior, though, by overriding the IP address using the uip parameter and setting it to an IP address of the actual requestor (not the server sending the request). If you don't know the IP address of the requestor, but you know his/her geographical location, you can use the geoid parameter instead.

    Note, the same problem often occurs with the UA string in the request header. If a single server is sending all the requests, Google Analytics will report them as all coming from the same device. You can similarly override the user agent using the ua parameter.