com.brsanthu.googleanalytics.ItemHit Maven / Gradle / Ivy
Show all versions of google-analytics-java Show documentation
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.brsanthu.googleanalytics;
import static com.brsanthu.googleanalytics.GoogleAnalyticsParameter.CURRENCY_CODE;
import static com.brsanthu.googleanalytics.GoogleAnalyticsParameter.ITEM_CATEGORY;
import static com.brsanthu.googleanalytics.GoogleAnalyticsParameter.ITEM_CODE;
import static com.brsanthu.googleanalytics.GoogleAnalyticsParameter.ITEM_NAME;
import static com.brsanthu.googleanalytics.GoogleAnalyticsParameter.ITEM_PRICE;
import static com.brsanthu.googleanalytics.GoogleAnalyticsParameter.ITEM_QUANTITY;
import static com.brsanthu.googleanalytics.GoogleAnalyticsParameter.TRANSACTION_ID;
/**
* GA request to track items as part of ecommerce transaction.
*
* For more information, see GA Parameters Reference
*
* @author Santhosh Kumar
*/
public class ItemHit extends GoogleAnalyticsRequest {
public ItemHit() {
super("item");
}
/**
*
*
* Required for transaction hit type.
*
* Required for item hit type.
*
* A unique identifier for the transaction. This value should be the same for both the Transaction hit and Items hits associated to the particular transaction.
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* ti
* text
* None
*
* 500 Bytes
*
* transaction, item
*
*
*
*
* Example value: OD564
* Example usage: ti=OD564
*
*
*/
public ItemHit txId(String value) {
setString(TRANSACTION_ID, value);
return this;
}
public String txId() {
return getString(TRANSACTION_ID);
}
/**
*
*
* Required for item hit type.
*
* Specifies the item name.
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* in
* text
* None
*
* 500 Bytes
*
* item
*
*
*
*
* Example value: Shoe
* Example usage: in=Shoe
*
*
*/
public ItemHit itemName(String value) {
setString(ITEM_NAME, value);
return this;
}
public String itemName() {
return getString(ITEM_NAME);
}
/**
*
*
* Optional.
*
* Specifies the price for a single item / unit.
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* ip
* currency
* 0
*
* None
*
* item
*
*
*
*
* Example value: 3.50
* Example usage: ip=3.50
*
*
*/
public ItemHit itemPrice(Double value) {
setDouble(ITEM_PRICE, value);
return this;
}
public Double itemPrice() {
return getDouble(ITEM_PRICE);
}
/**
*
*
* Optional.
*
* Specifies the number of items purchased.
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* iq
* integer
* 0
*
* None
*
* item
*
*
*
*
* Example value: 4
* Example usage: iq=4
*
*
*/
public ItemHit itemQuantity(Integer value) {
setInteger(ITEM_QUANTITY, value);
return this;
}
public Integer itemQuantity() {
return getInteger(ITEM_QUANTITY);
}
/**
*
*
* Optional.
*
* Specifies the SKU or item code.
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* ic
* text
* None
*
* 500 Bytes
*
* item
*
*
*
*
* Example value: SKU47
* Example usage: ic=SKU47
*
*
*/
public ItemHit itemCode(String value) {
setString(ITEM_CODE, value);
return this;
}
public String itemCode() {
return getString(ITEM_CODE);
}
/**
*
*
* Optional.
*
* Specifies the category that the item belongs to.
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* iv
* text
* None
*
* 500 Bytes
*
* item
*
*
*
*
* Example value: Blue
* Example usage: iv=Blue
*
*
*/
public ItemHit itemCategory(String value) {
setString(ITEM_CATEGORY, value);
return this;
}
public String itemCategory() {
return getString(ITEM_CATEGORY);
}
/**
*
*
* Optional.
*
* When present indicates the local currency for all transaction currency values. Value should be a valid ISO 4217 currency code.
*
*
*
* Parameter
* Value Type
* Default Value
* Max Length
* Supported Hit Types
*
*
* cu
* text
* None
*
* 10 Bytes
*
* transaction, item
*
*
*
*
* Example value: EUR
* Example usage: cu=EUR
*
*
*/
public ItemHit currencyCode(String value) {
setString(CURRENCY_CODE, value);
return this;
}
public String currencyCode() {
return getString(CURRENCY_CODE);
}
}