Saturday, January 10, 2015

Fixing Google Analytics Mobile Tracking

I have started using Google Analytics on a few different websites recently, and I noticed that the real-time report, and even the regular reports, do not show traffic from my mobile device, only desktop traffic. At first I thought it must be Google's fault - after all, I implemented the code exactly as outlined in their directions. However, after getting nowhere after a few minutes of searching around for solutions, it dawned on me - it is because I use an adblocker on my Android phone! AdAway, the adblocker I use, modifies the host file on the Android OS to block incoming traffic from advertisers - unfortunately, it categorizes Google Analytics as an advertiser and blocks the tracking code from running. Under system/etc/hosts, this is reflected by these lines of code:

To solve this, there are a few different options: