HitBuilders

public class HitBuilders extends Object

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")
         .setCustomDimension(1, "dimension1")
         .build());

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

t.setScreenName("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.setScreenName("Home");
 t.send(new HitBuilders.EventBuilder()
         .setScreenName("Popup Screen")
         .setCategory("click")
         .setLabel("popup")
         .build());
Additionally, The builder objects can be re-used to build values to be sent with multiple hits.
HitBuilders.TimingBuilder tb = new HitBuilders.TimingBuilder()
         .setCategory("category")
         .setValue(0L)
         .setVariable("name");
 t.send(tb.setValue(10).build());
 t.send(tb.setValue(20).build());

Nested Class Summary

class
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
A Builder object to build event hits. 
class
Exception builder allows you to measure the number and type of caught and uncaught crashes and exceptions that occur in your app. 
class
Internal class to provide common builder class methods. 
class
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
Class to build a screen view hit. 
class
A Builder object to build social event hits. 
class
Hit builder used to collect timing related data. 
class
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 Constructor Summary

Inherited Method Summary

Public Constructors

public HitBuilders ()

Create a Mobile Website
View Site in Mobile | Classic
Share by: