1

I am developing an Android application for which I am using Google Analytics v4. I am using concept of event tracking to understand user behavior.

I have following questions:

  1. What are happens to events which are generated when device is offline?
  2. What solution I need to integrate in my code so that I don't miss events generated when device was offline?

Thank you.

1 Answers1

1

For offline behaviour, you will need to store the events in a local database and sent them to GA when the phone gets online. For this, you will need to use the Google Analytics Measurement Protocol.

One of the most important parameters is queue time.

Queue time (qt) : Used to collect offline / latent hits. The value represents the time delta (in milliseconds) between when the hit being reported occurred and the time the hit was sent. The value must be greater than or equal to 0. Values greater than four hours may lead to hits not being processed.

So when a user clicks something or does any action you want to track, store the click with a timestamp. When the device gets online, while sending data to GA, calculate qt (current timestamp - stored timestamp). Note it's in milliseconds. This will ensure your GA has correct user behaviour.

The four hour limitation can be an issue. If you are looking for something with more time limit, use Mixpanel. It's SDK is built to store offline behaviour so you don't need to store events using your own code. It's free for 20M data points per month. There are other options like Mixpanel too which are built mobile first and free tier can cater up to good amount of needs.

Netham
  • 1,168
  • 6
  • 16
  • Thank you for the information. Can you share some resources such type of implementation for Android? – Nimesh Chandramaniya Oct 10 '16 at 06:35
  • 1
    I don't have access to my code right now, but to see what parameters you need to store and send use this tool https://ga-dev-tools.appspot.com/hit-builder/. You can set an event listener for connectivity change ( take a look at this http://stackoverflow.com/questions/25678216/android-internet-connectivity-change-listener) and then send data when connection is avaliable. Use the batch mode to send requests (see the Measurement protocol documentation) These all are POST requests so they should be easy to implement. – Netham Oct 10 '16 at 07:47
  • 2
    I found that GA handles offline event tracking automatically when device goes online. As I am not worried about time stamp of events, I am going with default option. – Nimesh Chandramaniya Oct 10 '16 at 07:58
  • 1
    That method has a downside: when the user goes online all the actions done offline will have the time stamp of the time they were sent to Google, not when they happened. – Netham Oct 10 '16 at 13:10