Auditing Google Analytics in an Android App

1. Tools

For the new SDK

– mHotspot 

Download: http://www.mhotspot.com/index.html

First, you need to share your LAN connection over Wi-Fi:

http://www.mhotspot.com/mhotspot-no-internet-access.html

Then open mHotspot and create a network (name and password). Finally, choose to share the LAN through the network you just set up and click Start Hotspot.

Image1

Video installation tutorial: http://www.mhotspot.com/index.html

– Charles Proxy

Download: http://www.charlesproxy.com/download/

Once it's downloaded, you need to set up SSL proxying so Charles accepts the Google Analytics requests.

Image2

You need to add google-analytics.com on port 80 and ssl.google-analytics.com on port 443.

This is what the settings should look like:

Image5

For the old SDK

The same tools as for the new SDK, plus:

– EffeTech HTTP Sniffer

Download: http://www.effetech.com/download/EffeTechHTTPSniffer.exe

Once EffeTech is installed, you need to install WinPcap. With WinPcap in place, download the msvcr71.dll library and put it in the EffeTech folder.

Video installation tutorial: 

http://blog.soporteti.net/redes/effetech-http-sniffer-como-instalarlo-y-ponerlo-en-funcionamiento/

2. The audit

Common steps

  • Open Charles Proxy. Check that it works by browsing the web and making sure you can see data being sent.
  • Find your IP address in the command prompt (Run -> cmd -> ipconfig -> Enter).Image4
  • On your phone, find the Wi-Fi network you created earlier (wifi-nat) and connect to it by editing its settings. Set the proxy to your IP address and the port to 8888 (the one Charles uses), then save.Image6
  • Wait for the phone to connect to the internet, and Charles will show a message like this one:Image3
  • Click Allow and you'll start receiving data from the traffic your phone generates.

For the new SDK

With the new SDK, you can see the apps' analytics data right in Charles Proxy. The data is sent via the Google Analytics Measurement Protocol, which works over HTTP (https://developers.google.com/analytics/devguides/collection/protocol/v1/reference).

For example, this is what you'd see when an event fires in the Booking.com app:

Image8

For the old SDK

Apps like PortAventura (a Spanish theme park resort) and Cinesa (a Spanish movie theater chain) use the old SDK, so their requests don't show up in Charles Proxy.

To see these requests, leave Charles open (it will act as the proxy) and then open EffeTech HTTP Sniffer.

Once it's open, select the network adapter you want to monitor:

Image7

Finally, hit Play and start using the app. For every page/event/… you trigger, look for the Google Analytics GIF request and check what is being sent in the HTTP Request Header (in the bottom panel).

In the next image you can see a page from the Cinesa app:

Image9

Natzir Turrado 03 April 2012

Share

Facebook Linkedin Twitter

More articles

Regular Expressions (RegEx) for Analytics and SEO

Regular Expressions (RegEx) are a must if you work in web analytics and SEO. They're also one of the biggest headaches for those of us in this field. How many times have we fought with a Google Analytics filter or an advanced segment? That's why I decided to put together a bunch of useful resources […]

Read more

Inference: The Most Important Part of Testing That Nobody Told You About

Now that testing is (finally) becoming trendy, people are making rookie mistakes, as always happens when you start something new. The first one is running tests based on best practices. I won't get into that here, because at the end of the day those tests do work (even if only 10% of the time). And […]

Read more