Courtesy: GitHub

Google Analytics Quickstart

Google Analytics Android Quickstart app demonstrates collecting app usage analytics via Tracker available in Google Play Services. HitBuilders.ScreenViewBuilder is used to send screen view analytics.


Getting Started

  • Follow the quickstart guide to set up your project in Android Studio.
    • Make sure to replace ga_trackingId in res/xml/global_tracker.xml with your Google Analytics tracking ID.
  • Run the sample on your Android device or emulator.
  • Swipe between images to register screen views.
  • View collected analytics via Google Analytics.




If you've found an error in this sample, please file an issue:

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub.


Copyright 2015 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

compileSdkVersion 25

applicationId ""

minSdkVersion 14

targetSdkVersion 25

versionCode 1

versionName "1.0"

compile ''

compile ''

compile ''

compile ''



  • android.permission.INTERNET
  • android.permission.ACCESS_NETWORK_STATE

application .AnalyticsApplication


Activity which displays numerous background images that may be viewed. These background images are shown via {@link ImageFragment}.

The {@link} that will provide fragments for each image. This uses a {@link FragmentPagerAdapter}, which keeps every loaded fragment in memory.

The {@link ViewPager} that will host the patterns.

The {@link Tracker} used to record screen views.

Return the title of the currently displayed image. @return title of image

Record a screen view hit for the visible {@link ImageFragment} displayed inside {@link FragmentPagerAdapter}.

Check to make sure global_tracker.xml was configured correctly (this function only needed for sample apps).

A {@link FragmentPagerAdapter} that returns a fragment corresponding to one of the sections/tabs/pages.