HitBuilders | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Nested Classes | Ctors | Inherited Methods | [Expand All]
public class

# HitBuilders

extends Object

java.lang.Object
↳ | com.google.android.gms.analytics.HitBuilders

## Class Overview

Helper class to build a map of hit parameters and values.

Examples:
This will send a event hit type with the specified parameters and a custom dimension parameter.

     Tracker t = // get a tracker.
     t.send(
         new HitBuilders.EventBuilder().setCategory("EventCategory").setAction("EventAction")
         .set(Fields.CustomDimension(1), "dimension1")
         .build());

If you want to send a parameter with all hits, set it on Tracker directly.

     t.set(Fields.SCREEN_NAME, "Home");
     t.send(
          new HitBuilders.SocialBuilder().setNetwork("Google+").setAction("PlusOne")
          .setTarget("SOME_URL").build());
     t.send(
          new HitBuilders.SocialBuilder().setNetwork("Google+").setAction("Share")
          .setTarget("SOME_POST").build());
     t.send(
          new HitBuilders.SocialBuilder().setNetwork("Google+").setAction("HangOut")
          .setTarget("SOME_CIRCLE").build());

You can override a value set on the tracker by adding it to the map.

     t.set(Fields.SCREEN_NAME, "Home");
     t.send(...);
     t.send(
         new HitBuilders.EventBuilder().setCategory("click").setLabel("popup")
         .set(Fields.SCREEN_NAME, "popup title")
         .build());

Additionally, The builder objects can be re-used to build values to be sent with multiple hits.

     TimingBuilder tb = new HitBuilders.TimingBuilder().setCategory("category").setValue(0L)
          .setVariable("name");
     t.send(tb.set(Fields.EVENT_VALUE, "10").build());
     t.send(tb.set(Fields.EVENT_VALUE, "20").build());

## Summary

Nested Classes
class | HitBuilders.AppViewBuilder | This class is deprecated. This class has been deprecated in favor of the new ScreenViewBuilder class. The two classes are semantically similar but the latter is consistent across all the Google Analytics platforms.
class | HitBuilders.EventBuilder | A Builder object to build event hits.
class | HitBuilders.ExceptionBuilder | Exception builder allows you to measure the number and type of caught and uncaught crashes and exceptions that occur in your app.
class | HitBuilders.HitBuilder<T extends HitBuilder> | Internal class to provide common builder class methods.
class | HitBuilders.ItemBuilder | This class is deprecated. This class has been deprecated in favor of a richer set of APIs on all the HitBuilder classes. With the new approach, simply use addProduct, addImpression, addPromo and setAction to add ecommerce data to any of the hits.
class | HitBuilders.ScreenViewBuilder | Class to build a screen view hit.
class | HitBuilders.SocialBuilder | A Builder object to build social event hits.
class | HitBuilders.TimingBuilder | Hit builder used to collect timing related data.
class | HitBuilders.TransactionBuilder | This class is deprecated. This class has been deprecated in favor of a richer set of APIs on all the HitBuilder classes. With the new approach, simply use addProduct, addImpression, addPromo and setAction to add ecommerce data to any of the hits.

Public Constructors
| HitBuilders()

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)

## Public Constructors

#### public HitBuilders ()