google-analytic measurement endpoint is ignoring x-forwarded-for header! any solution?

冷暖自知 提交于 2019-12-10 21:37:44

问题


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



来源:https://stackoverflow.com/questions/15323748/google-analytic-measurement-endpoint-is-ignoring-x-forwarded-for-header-any-sol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!