8

i'm using google analytics on Android and it gives me a lot of avg session duration: 00:00:00

please note that i'm not using "ga_autoActivityTracking" and i have more than one activity

here's my code

build.gradle

 compile 'com.google.android.gms:play-services-analytics:7.5.0'

Application class

Tracker mTracker = GoogleAnalytics.getInstance(context).newTracker(R.xml.tracker);

tracker.xml

<resources xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="TypographyDashes">
    <!-- Replace placeholder GA tracking Id with a real one. -->
    <string name="ga_trackingId">UA-1111111-1</string>
    <bool name="ga_reportUncaughtExceptions">true</bool>
    <integer name="ga_sessionTimeout">300</integer>

    <!-- 1800 seconds is 30 minutes, which is the default.
        Included explicitly for ease of tweaking. -->
    <integer name="ga_dispatchInterval">1800</integer>

    <bool name="ga_debug">false</bool>
</resources>

i send screenviews on onStart function or onPageSelected within a viewpager

public static void sendScreenView(String screenName) {
        if (canSend()) {
            mTracker.setScreenName(screenName);
            mTracker.send(new HitBuilders.AppViewBuilder()
                    .setCustomDimension(COUNTRY_INDEX, getCountryCode()).build());
            Timber.i(TAG, "Screen View recorded: " + screenName);
        } else {
            Timber.i(TAG, "Screen View NOT recorded (analytics disabled or not ready).");
        }
    }
Omar Abdan
  • 1,901
  • 17
  • 29

4 Answers4

-1

What is your Bounce Rate? If it is ~100%, there may not be any problem with your code, and instead with the UX/UI of your app.

adastra21
  • 83
  • 1
  • 1
  • 9
-1

If you haven't already, try setting auto activity tracking to true.

tracker.enableAutoActivityTracking(true);

Usually you do this in a class that extends Application.

Chris W
  • 785
  • 8
  • 18
-1

try this tutorial where you can track manually activities or fragments

full source code and step by step instruction: click hare

nirav kalola
  • 1,220
  • 13
  • 17
-1

Refer the link given below, its for Eclipse but i think it can help you to solve your problem.

How to integrate Google Analytics in Android app

Community
  • 1
  • 1
Pravinsingh Waghela
  • 2,516
  • 4
  • 32
  • 50