public class

Product

extends Object
java.lang.Object
   ↳ com.google.android.gms.analytics.ecommerce.Product

Class Overview

Class to construct product related information for a Google Analytics hit. Use this class to report information about products sold by merchants or impressions of products seen by users. Instances of this class can be associated with both ProductActions via addProduct(Product) and Product Impressions via addImpression(Product, String). Typical usage:

          ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder();
          builder.addImpression(
              new Product()
                  .setId("PID-1234")
                  .setName("Space Monkeys!")
                  .setPrice(100)
                  .setQuantity(2), "listName");

          builder.setProductAction(
              new ProductAction(ProductAction.ACTION_PURCHASE))
                  .addProduct(new Product().setId("PID-4321").setName("Water Monkeys!"));
          tracker.send(builder.build());
     

Summary

Public Constructors
Product()
Public Methods
Product setBrand(String value)
Sets the brand associated with the product in GA reports.
Product setCategory(String value)
Sets the category associated with the product in GA reports.
Product setCouponCode(String value)
Sets the coupon code associated with the product.
Product setCustomDimension(int index, String value)
Sets the custom dimensions associated with the product.
Product setCustomMetric(int index, int value)
Sets the custom metrics associated with the product.
Product setId(String value)
Sets the id that is used to identify a product in GA reports.
Product setName(String value)
Sets the name that is used to identify the product in GA reports.
Product setPosition(int value)
Sets the position of the product on the page/product impression list etc.
Product setPrice(double value)
Sets the price of the product.
Product setQuantity(int value)
Sets the quantity of the product.
Product setVariant(String value)
Sets the variant of the product.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Product ()

Public Methods

public Product setBrand (String value)

Sets the brand associated with the product in GA reports.

Parameters
value The product's brand. Example: "Acme Toys"
Returns
  • Returns the same object to enable chaining of methods.

public Product setCategory (String value)

Sets the category associated with the product in GA reports.

Parameters
value The product's category. Example: "Toys"
Returns
  • Returns the same object to enable chaining of methods.

public Product setCouponCode (String value)

Sets the coupon code associated with the product. This field is usually not used with product impressions.

Parameters
value The product's coupon code. Example: "EXTRA10"
Returns
  • Returns the same object to enable chaining of methods.

public Product setCustomDimension (int index, String value)

Sets the custom dimensions associated with the product.

Parameters
index The dimension's index as configured in Google Analytics Account. Example: 3
value The product's custom dimension. Example: "Foo Reseller"
Returns
  • Returns the same object to enable chaining of methods.

public Product setCustomMetric (int index, int value)

Sets the custom metrics associated with the product.

Parameters
index The metric's index as configured in Google Analytics Account. Example: 4
value The product's custom metric. Example: 5
Returns
  • Returns the same object to enable chaining of methods.

public Product setId (String value)

Sets the id that is used to identify a product in GA reports.

Parameters
value The product id.
Returns
  • Returns the same object to enable chaining of methods.

public Product setName (String value)

Sets the name that is used to identify the product in GA reports.

Parameters
value The product's name. Example: "Space Monkeys"
Returns
  • Returns the same object to enable chaining of methods.

public Product setPosition (int value)

Sets the position of the product on the page/product impression list etc.

Parameters
value The product's position. Example: 1 or 30
Returns
  • Returns the same object to enable chaining of methods.

public Product setPrice (double value)

Sets the price of the product.

Parameters
value The product's price. Example: 3.14
Returns
  • Returns the same object to enable chaining of methods.

public Product setQuantity (int value)

Sets the quantity of the product. This field is usually not used with product impressions.

Parameters
value The product's quantity. Example: 42
Returns
  • Returns the same object to enable chaining of methods.

public Product setVariant (String value)

Sets the variant of the product.

Parameters
value The product's variant. Example: "Yellow" or "Red"
Returns
  • Returns the same object to enable chaining of methods.