unicef / iogt

BSD 2-Clause "Simplified" License
25 stars 35 forks source link

Google Analytics doesn't populate location information for many users #1405

Open cbunicef opened 2 years ago

cbunicef commented 2 years ago

This is an issue that has been around since before V2. There are a considerable number of users that don't have location information in Google Analytics:

image

The historical theory has been that these are feature phone users, or perhaps Facebook Free Basics users.

I thought I had seen reports that Google changed its methodology on tracking location, which led to more "not set" values, but I can't find them now, maybe I am misremembering.

Here is some info about Free Basics and IP addresses:

https://developers.facebook.com/docs/internet-org/platform-technical-guidelines/

IP Addresses

Since requests pass through the Internet.org proxy, the HTTP Request IP address will always be from our servers instead of from the original requestor. You can obtain the original requestor IP from X-IORG-FBS-UIP HTTP header field (which is created by our proxy).

Our proxy also follows the X-Forwarded-For convention, so the same IP address will be found in that field as well (as a first non-private IP address).

Be aware that, because of the SSL encryption, the Free Basics Android app does not support the x-iorg-fbs-uip and x-iorg-fbs HTTP header fields.

Google Analytics To make it easier to use Google Analytics without JavaScript inside Free Basics Platform, below are some guidelines on setting up your service.

Detecting country To correctly detect user's country, you need to correctly fill the UIP override parameter for Google Analytics request. The easiest way to do so is to utilize X-IORG-FBS-UIP HTTP header field (see Internet.org proxy). The UIP parameter would have to be set server-side for the request to Google Analytics.

istride commented 2 years ago

The software component that is doing the tracking looks for the client's IP address in the X-Forwarded-For HTTP header, in the first instance:

https://github.com/praekeltfoundation/django-google-analytics/blob/b0b158c021aca9fd92fddeec240f90a626213f67/google_analytics/utils.py#L83

I think there's nothing more that the app can do to pass the correct information to Google, and we need to look into how the app is being deployed to find answers. I have raised an issue (in DevOps) for an investigation into the infrastructure.