protected static class

HitBuilders.HitBuilder

extends Object
java.lang.Object
   ↳ com.google.android.gms.analytics.HitBuilders.HitBuilder<T extends com.google.android.gms.analytics.HitBuilders.HitBuilder>
Known Direct Subclasses

Class Overview

Internal class to provide common builder class methods. The most important methods from this class are the setXYZ and build methods. These methods can be used to set individual properties on the hit and then build it so that it is ready to be passed into the tracker.

Summary

Protected Constructors
HitBuilders.HitBuilder()
Public Methods
T addImpression(Product product, String impressionList)
Adds a product impression to the hit.
T addProduct(Product product)
Adds product information to be sent with a given hit.
T addPromotion(Promotion promotion)
Adds promotion related information to the hit.
Map<String, String> build()
Builds a Map of parameters and values that can be set on the Tracker object.
final T set(String paramName, String paramValue)
Sets the value for the given parameter name.
final T setAll(Map<String, String> params)
Adds a set of key, value pairs to the hit builder.
T setCampaignParamsFromUrl(String utmParams)
Parses and translates utm campaign parameters to analytics campaign parameters and returns them as a map.
T setCustomDimension(int index, String dimension)
Adds a custom dimension to the current hit builder.
T setCustomMetric(int index, float metric)
Adds a custom metric to the current hit builder.
T setNewSession()
T setNonInteraction(boolean nonInteraction)
T setProductAction(ProductAction action)
Sets a product action for all the products included in this hit.
T setPromotionAction(String action)
Adds an action associated with the promotions in a given hit.
Protected Methods
String get(String paramName)
T setHitType(String hitType)
Sets the type of the hit to be sent.
[Expand]
Inherited Methods
From class java.lang.Object

Protected Constructors

protected HitBuilders.HitBuilder ()

Public Methods

public T addImpression (Product product, String impressionList)

Adds a product impression to the hit. The product can be optionally associated with a named impression list.

Parameters
product Product
impressionList String
Returns
T

public T addProduct (Product product)

Adds product information to be sent with a given hit. The action provided in setProductAction(ProductAction) affects how the products passed in through this method get processed.

Parameters
product Product
Returns
T

public T addPromotion (Promotion promotion)

Adds promotion related information to the hit.

Parameters
promotion Promotion
Returns
T

public Map<String, String> build ()

Builds a Map of parameters and values that can be set on the Tracker object.

Returns
Map<String, String> A map of string keys to string values that can be passed into the tracker for one or more hits.

public final T set (String paramName, String paramValue)

Sets the value for the given parameter name. These values will be added to the hit when it is built. This function should only be used for advanced cases where none of the explicit setters do not work. This function should usually be called after all the explicit setter have been called.

Parameters
paramName String: The name of the parameter that should be sent over wire. This value should start with "&".
paramValue String: The value to be sent over the wire for the given parameter.
Returns
T The builder object that you can use to chain calls.

public final T setAll (Map<String, String> params)

Adds a set of key, value pairs to the hit builder. These values will be added to the hit when it is built. This function should only be used for advanced cases where none of the explicit setters work. This function should usually be called after all the explicit setter have been called.

Parameters
params Map: A map of all the values to be added to the builder.
Returns
T The builder object that you can use to chain calls.

public T setCampaignParamsFromUrl (String utmParams)

Parses and translates utm campaign parameters to analytics campaign parameters and returns them as a map.

Parameters
utmParams String: url containing utm campaign parameters.
Returns
T The builder object that you can use to chain calls. Valid campaign parameters are:
  • utm_id
  • utm_campaign
  • utm_content
  • utm_medium
  • utm_source
  • utm_term
  • dclid
  • gclid
  • gmob_t

Example: http://my.site.com/index.html?utm_campaign=wow&utm_source=source utm_campaign=wow&utm_source=source.

For more information on auto-tagging, see http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55590

For more information on manual tagging, see http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55518 *

public T setCustomDimension (int index, String dimension)

Adds a custom dimension to the current hit builder. Calling this method with the same index will overwrite the previous dimension with the new one. Refer http://goo.gl/igziD2 for details on how to set the custom dimensions up.

Parameters
index int: The index/slot in which the dimension will be set.
dimension String: The value of the dimension for the given index.
Returns
T The builder object that you can use to chain calls.

public T setCustomMetric (int index, float metric)

Adds a custom metric to the current hit builder. Calling this method with the same index will overwrite the previous metric with the new one. Refer http://goo.gl/igziD2 for details on how to set the custom metrics up.

Parameters
index int: The index/slot in which the metric will be set.
metric float: The value of the metric for the given index.
Returns
T The builder object that you can use to chain calls.

public T setNewSession ()

Returns
T

public T setNonInteraction (boolean nonInteraction)

Parameters
nonInteraction boolean
Returns
T

public T setProductAction (ProductAction action)

Sets a product action for all the products included in this hit. The action and its associated properties affect how the products added through addProduct(Product) are processed.

Parameters
action ProductAction
Returns
T

public T setPromotionAction (String action)

Adds an action associated with the promotions in a given hit. Valid values for an action are defined in Promotion class.

Parameters
action String
Returns
T

Protected Methods

protected String get (String paramName)

Parameters
paramName String
Returns
String

protected T setHitType (String hitType)

Sets the type of the hit to be sent. This can be used to reuse the builder object for multiple hit types. See http://goo.gl/kMRwhS for possible hit values.

Parameters
hitType String: The value of the Hit.
Returns
T