Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google analytics doesn't show the active user in Real time overview

i have setup every thing in my app for using google analytics V4 and i get every things working and i can see it but when i go to real time overview in my mobile view i didn't see any active user

this is my tracker

 <?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:ignore="TypographyDashes">
  <integer name="ga_sessionTimeout">300</integer>

    <!-- Enable automatic Activity measurement -->
    <bool name="ga_autoActivityTracking">true</bool>
    <!-- The screen names that will appear in reports -->
    <screenName name="info.lifepast.MainActivity">MainActivity</screenName>

    <!--  The following value should be replaced with correct property id. -->
    <string name="ga_trackingId">UA-xxx-3</string>
</resources>

and the application class is

public class Analytics extends Application {
private static final String PROPERTY_ID = "UA-xxxxx-3";
  public enum TrackerName {
        APP_TRACKER, // Tracker used only in this app.
        GLOBAL_TRACKER, // Tracker used by all the apps from a company. eg: roll-up tracking.
        ECOMMERCE_TRACKER, // Tracker used by all ecommerce transactions from a company.
    } 

    HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();
    synchronized Tracker getTracker(TrackerName trackerId) {
        if (!mTrackers.containsKey(trackerId)) {

          GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
          Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker(PROPERTY_ID)
              : (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker)
                  : analytics.newTracker(R.xml.ecommerce_tracker);
          mTrackers.put(trackerId, t);

        }
        return mTrackers.get(trackerId);
      }

}

and in my main activity on create i added this

Tracker t = ((Analytics) this.getApplication()).getTracker(
        TrackerName.GLOBAL_TRACKER);
    GoogleAnalytics.getInstance(this).getLogger().setLogLevel(LogLevel.VERBOSE);
    // Set screen name.
    // Where path is a String representing the screen name.
    t.setScreenName(getString(R.string.app_name));

    // Send a screen view.
    t.send(new HitBuilders.AppViewBuilder().build());

and the manifest file

  <meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" /> 
    <meta-data
        android:name="com.google.android.gms.analytics.globalConfigResource"
        android:resource="@xml/global_tracker"/>

any help?

like image 450
Antwan Avatar asked Sep 20 '14 14:09

Antwan


People also ask

How do I see active users in Google Analytics?

See Active Users dataSign in to Google Analytics. Navigate to your view. Open Reports. Select Audience > Active Users.

Why is real-time not working in Google Analytics?

No data at all in the Real-Time reports? If you don't see any data at all in your Real-Time reports, then the most likely cause is an issue with the Google Analytics tracking code. The first thing to do is to check that the correct tracking code is installed on your website.

How do we define active user in real-time report?

Active users are those who have sent a hit to Analytics within the last five minutes. Active users per page is the number of users who have sent their most recent hit from that page.

Does Google Analytics report in real-time?

See Real-Time dataReal-Time is available in all Analytics accounts. No changes to the tracking code are necessary. To see Real-Time: Sign in to Google Analytics..


2 Answers

I've been looking at the v4 analytics today, and have also had trouble getting screen views to post. Here are a couple things I've dug up during my investigations that may be helpful for you:

  • AppViewBuilder is deprecated in favor of ScreenViewBuilder (see the HitBuilders source code). This part of the documentation is, presumably, out of date. Edit Mar 6, 2015: it would appear that the linked documentation has now been updated to use ScreenViewBuilder.

  • If my interpretation of the documentation is correct, it should not be necessary to explicitly post screen views using a ScreenViewBuilder when the auto activity tracking feature is enabled (which I see is the case in your configuration file).

  • By default, the current date is not included in your Google Analytics stats. You can choose to include it by manually selecting a date range (see drop-down control at the top right of most GA pages).

  • Make sure you shorten the dispatch period for debug builds - by default, events are batched and sent every 30 minutes, but for testing it's ok to reduce this to a few seconds. See the answer from @vangoz for implementation details.

Hope some of that helps you.

Edit: related, but I see you've already posted there: Google Analytics API v4 for Android Does NOT Send Screen Views

like image 63
stkent Avatar answered Oct 29 '22 04:10

stkent


For me it turns out Google Analytics only dispatch the data every 30 minutes by default. So changing the dispatch time for testing show the realtime data with some delay.

GoogleAnalytics.getInstance(this).setLocalDispatchPeriod(15);

Reference: https://developers.google.com/analytics/devguides/collection/android/v4/dispatch

like image 25
vangoz Avatar answered Oct 29 '22 04:10

vangoz