Summary: Constants | Ctors | Methods | Inherited Methods | [Expand All]
public class

# ProductAction

extends Object

java.lang.Object
↳ | com.google.android.gms.analytics.ecommerce.ProductAction

## Class Overview

Class to construct transaction/checkout or other product interaction related information for a Google Analytics hit. Use this class to report information about products sold, viewed or refunded. This class is intended to be used with `Product`. Instances of this class can be associated with `setProductAction(ProductAction)`. Typical usage:

              HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder();

              builder.setProductAction(
                  new ProductAction(ProductAction.ACTION_PURCHASE)
                      .setTransactionId("TT-1234")
                      .setTransactionRevenue(3.14)
                      .setTransactionCouponCode("EXTRA100"))
                  .addProduct(new Product().setId("PID-4321").setName("Water Monkeys!"));
              tracker.send(builder.build());

## Summary

Constants
String | ACTION_ADD | Action to use when a product is added to the cart.
String | ACTION_CHECKOUT | Action to use for hits with checkout data.
String | ACTION_CHECKOUT_OPTION | Action to be used for supplemental checkout data that needs to be provided after a checkout hit.
String | ACTION_CHECKOUT_OPTIONS | This constant is deprecated. Use `ACTION_CHECKOUT_OPTION` instead.
String | ACTION_CLICK | Action to use when the user clicks on a set of products.
String | ACTION_DETAIL | Action to use when the user views detailed descriptions of products.
String | ACTION_PURCHASE | Action that is used to report all the transaction data to GA.
String | ACTION_REFUND | Action to use while reporting refunded transactions to GA.
String | ACTION_REMOVE | Action to use when a product is removed from the cart.

Public Constructors
| ProductAction(String action) Sets the product action for all the products included in the hit.

Public Methods
ProductAction | setCheckoutOptions(String value) Sets the label associated with the checkout.
ProductAction | setCheckoutStep(int value) Sets the checkout processes's progress.
ProductAction | setProductActionList(String value) Sets the list name associated with the products in the analytics hit.
ProductAction | setProductListSource(String value) Sets the list source name associated with the products in the analytics hit.
ProductAction | setTransactionAffiliation(String value) Sets the transaction's affiliation value.
ProductAction | setTransactionCouponCode(String value) Sets the coupon code used in a transaction.
ProductAction | setTransactionId(String value) The unique id associated with the transaction.
ProductAction | setTransactionRevenue(double value) Sets the transaction's total revenue.
ProductAction | setTransactionShipping(double value) Sets the transaction's shipping costs.
ProductAction | setTransactionTax(double value) Sets the transaction's total tax.
String | toString()

[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(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Constants

#### public static final String ACTION_ADD

Action to use when a product is added to the cart.

Constant Value: "add"

#### public static final String ACTION_CHECKOUT

Action to use for hits with checkout data. This action can have accompanying fields like checkout step `setCheckoutStep(int)`, checkout label `setCheckoutOptions(String)` and checkout options `setCheckoutOptions(String)`.

Constant Value: "checkout"

#### public static final String ACTION_CHECKOUT_OPTION

Action to be used for supplemental checkout data that needs to be provided after a checkout hit. This action can additionally have the same fields as the checkout action.

Constant Value: "checkout_option"

#### public static final String ACTION_CHECKOUT_OPTIONS

This constant is deprecated.
Use `ACTION_CHECKOUT_OPTION` instead.

Action to be used for supplemental checkout data that needs to be provided after a checkout hit. This action can additionally have the same fields as the checkout action.

Constant Value: "checkout_options"

#### public static final String ACTION_CLICK

Action to use when the user clicks on a set of products. This action can have accompanying fields like product action list name `setProductActionList(String)` and product list source `setProductListSource(String)`.

Constant Value: "click"

#### public static final String ACTION_DETAIL

Action to use when the user views detailed descriptions of products. This action can have accompanying fields like product action list name `setProductActionList(String)` and product list source `setProductListSource(String)`.

Constant Value: "detail"

#### public static final String ACTION_PURCHASE

Action that is used to report all the transaction data to GA. This is equivalent to the transaction hit type which was available in previous versions of the SDK. This action can can also have accompanying fields like transaction id, affiliation, revenue, tax, shipping and coupon code. These fields can be specified with methods defined in this class.

Constant Value: "purchase"

#### public static final String ACTION_REFUND

Action to use while reporting refunded transactions to GA.

Constant Value: "refund"

#### public static final String ACTION_REMOVE

Action to use when a product is removed from the cart.

Constant Value: "remove"

## Public Constructors

#### public ProductAction (String action)

Sets the product action for all the products included in the hit. Valid values include "detail", "click", "add", "remove", "checkout", "checkout_option", "purchase" and "refund". All these values are also defined in this class for ease of use. You also also send additional values with the hit for some specific actions. See the action documentation for details.

##### Parameters

action | The value of product action.

## Public Methods

#### public ProductAction setCheckoutOptions (String value)

Sets the label associated with the checkout. This value is used with `ACTION_CHECKOUT` and `ACTION_CHECKOUT_OPTION` actions.

##### Parameters

value | A string label/option associated with the checkout.

##### Returns

- Returns the same object to enable chaining of methods.

#### public ProductAction setCheckoutStep (int value)

Sets the checkout processes's progress. This value is used with `ACTION_CHECKOUT` and `ACTION_CHECKOUT_OPTION` actions.

##### Parameters

value | An integer representing the progress of the checkout flow. example: 4 or 5.

##### Returns

- Returns the same object to enable chaining of methods.

#### public ProductAction setProductActionList (String value)

Sets the list name associated with the products in the analytics hit. This value is used with `ACTION_DETAIL` and `ACTION_CLICK` actions.

##### Parameters

value | A string name identifying the product list.

##### Returns

- Returns the same object to enable chaining of methods.

#### public ProductAction setProductListSource (String value)

Sets the list source name associated with the products in the analytics hit. This value is used with `ACTION_DETAIL` and `ACTION_CLICK` actions.

##### Parameters

value | A string name identifying the product list's source.

##### Returns

- Returns the same object to enable chaining of methods.

#### public ProductAction setTransactionAffiliation (String value)

Sets the transaction's affiliation value. This value is used for `ACTION_PURCHASE` and `ACTION_REFUND` actions.

##### Parameters

value | A string identifying the transaction affiliation.

##### Returns

- Returns the same object to enable chaining of methods.

#### public ProductAction setTransactionCouponCode (String value)

Sets the coupon code used in a transaction. This value is used for `ACTION_PURCHASE` and `ACTION_REFUND` actions.

##### Parameters

value | A string representing the coupon code used in a transaction.

##### Returns

- Returns the same object to enable chaining of methods.

#### public ProductAction setTransactionId (String value)

The unique id associated with the transaction. This value is used for `ACTION_PURCHASE` and `ACTION_REFUND` actions.

##### Parameters

value | A string id identifying a transaction

##### Returns

- Returns the same object to enable chaining of methods.

#### public ProductAction setTransactionRevenue (double value)

Sets the transaction's total revenue. This value is used for `ACTION_PURCHASE` and `ACTION_REFUND` actions.

##### Parameters

value | A number representing the revenue from a transaction.

##### Returns

- Returns the same object to enable chaining of methods.

#### public ProductAction setTransactionShipping (double value)

Sets the transaction's shipping costs. This value is used for `ACTION_PURCHASE` and `ACTION_REFUND` actions.

##### Parameters

value | A number representing the shipping costs from a transaction.

##### Returns

- Returns the same object to enable chaining of methods.

#### public ProductAction setTransactionTax (double value)

Sets the transaction's total tax. This value is used for `ACTION_PURCHASE` and `ACTION_REFUND` actions.

##### Parameters

value | A number representing the revenue from a transaction.

##### Returns

- Returns the same object to enable chaining of methods.

#### public String toString ()