google-analytic measurement endpoint is ignoring x

2019-07-04 02:21发布

问题:

Recently, I began playing with GA Measurement protocol, it has huge potential for custom-made apps, especially for event tracking of webapps.

The problem I'm facing is; GA is always using the requester's IP as the source IP!

even GA docs says;

"IP Address – Is implicitly sent in the HTTP request and is used to compute all the geo / network dimensions in Google Analytics."

That's a big problem! Why?
As in my case;
I'm proxying different tracking calls thru one backend hosted in Heroku. And funny enough, all tracked calls appears to be from US (Heroku) in that case....

There should be a better solution!
Has anyone dealt with similar problem and any suggested solution to tackle this problem?

回答1:

This isnt supported yet (as of Sept 2013). There is a Google Group thread that is tracking this feature request. I Google team member has said they are considering it.

https://groups.google.com/forum/#!topic/google-analytics-measurement-protocol/8TAp7_I1uTk

Update on Feb 24, 2014
This feature has been added to Google Universal Analytics. The parameter name is 'uip'. It should be a valid IP address. It will always be anonymized just as though aip (anonymize IP) had been used.



回答2:

I'm working on the same issue. Here is a possible solution I've come up with to track geolocalisation: When making the call to GA, add the requester IP to a custom variable[1]. Now you can export all your GA data and translate this IP (from your custom variable) to a location (MaxMind[2]'s databases seem good, and are under CC) and display it yourself.

1: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables

2: http://dev.maxmind.com/geoip/geolite#IP_Geolocation-1