All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.brsanthu.googleanalytics.request.TransactionHit Maven / Gradle / Ivy

/*
 * 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.request;

import static com.brsanthu.googleanalytics.internal.Constants.HIT_TXN;
import static com.brsanthu.googleanalytics.request.GoogleAnalyticsParameter.CURRENCY_CODE;
import static com.brsanthu.googleanalytics.request.GoogleAnalyticsParameter.TRANSACTION_AFFILIATION;
import static com.brsanthu.googleanalytics.request.GoogleAnalyticsParameter.TRANSACTION_ID;
import static com.brsanthu.googleanalytics.request.GoogleAnalyticsParameter.TRANSACTION_REVENUE;
import static com.brsanthu.googleanalytics.request.GoogleAnalyticsParameter.TRANSACTION_SHIPPING;
import static com.brsanthu.googleanalytics.request.GoogleAnalyticsParameter.TRANSACTION_TAX;

/**
 * GA request to track ecommerce transaction.
 *
 * 

* For more information, see * GA Parameters * Reference *

* * @author Santhosh Kumar */ public class TransactionHit extends GoogleAnalyticsRequest { public TransactionHit() { this(null); } public TransactionHit(String txId) { this(txId, null); } public TransactionHit(String txId, Double txRevenue) { this(txId, null, txRevenue); } public TransactionHit(String txId, String txAffiliation, Double txRevenue) { this(txId, txAffiliation, txRevenue, null, null, "USD"); } public TransactionHit(String txId, String txAffiliation, Double txRevenue, String currencyCode) { this(txId, txAffiliation, txRevenue, null, null, currencyCode); } public TransactionHit(String txId, String txAffiliation, Double txRevenue, Double txShipping, Double txTax, String currencyCode) { super(HIT_TXN); txId(txId); txAffiliation(txAffiliation); txRevenue(txRevenue); txShipping(txShipping); txTax(txTax); currencyCode(currencyCode); } /** *
*

* 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. *

* * * * * * * * * * * * * * * * * *
ParameterValue TypeDefault ValueMax LengthSupported Hit Types
titextNone500 Bytestransaction, item
*
Example value: OD564
* Example usage: ti=OD564
*/ public TransactionHit txId(String value) { setString(TRANSACTION_ID, value); return this; } public String txId() { return getString(TRANSACTION_ID); } /** *
*

* Optional. *

*

* Specifies the affiliation or store name. *

* * * * * * * * * * * * * * * * * *
ParameterValue TypeDefault ValueMax LengthSupported Hit Types
tatextNone500 Bytestransaction
*
Example value: Member
* Example usage: ta=Member
*/ public TransactionHit txAffiliation(String value) { setString(TRANSACTION_AFFILIATION, value); return this; } public String txAffiliation() { return getString(TRANSACTION_AFFILIATION); } /** *
*

* Optional. *

*

* Specifies the total revenue associated with the transaction. This value should include any shipping or tax costs. *

* * * * * * * * * * * * * * * * * *
ParameterValue TypeDefault ValueMax LengthSupported Hit Types
trcurrency0Nonetransaction
*
Example value: 15.47
* Example usage: tr=15.47
*/ public TransactionHit txRevenue(Double value) { setDouble(TRANSACTION_REVENUE, value); return this; } public Double txRevenue() { return getDouble(TRANSACTION_REVENUE); } /** *
*

* Optional. *

*

* Specifies the total shipping cost of the transaction. *

* * * * * * * * * * * * * * * * * *
ParameterValue TypeDefault ValueMax LengthSupported Hit Types
tscurrency0Nonetransaction
*
Example value: 3.50
* Example usage: ts=3.50
*/ public TransactionHit txShipping(Double value) { setDouble(TRANSACTION_SHIPPING, value); return this; } public Double txShipping() { return getDouble(TRANSACTION_SHIPPING); } /** *
*

* Optional. *

*

* Specifies the total tax of the transaction. *

* * * * * * * * * * * * * * * * * *
ParameterValue TypeDefault ValueMax LengthSupported Hit Types
ttcurrency0Nonetransaction
*
Example value: 11.20
* Example usage: tt=11.20
*/ public TransactionHit txTax(Double value) { setDouble(TRANSACTION_TAX, value); return this; } public Double txTax() { return getDouble(TRANSACTION_TAX); } /** *
*

* Optional. *

*

* When present indicates the local currency for all transaction currency values. Value should be a valid ISO 4217 * currency code. *

* * * * * * * * * * * * * * * * * *
ParameterValue TypeDefault ValueMax LengthSupported Hit Types
cutextNone10 Bytestransaction, item
*
Example value: EUR
* Example usage: cu=EUR
*/ public TransactionHit currencyCode(String value) { setString(CURRENCY_CODE, value); return this; } public String currencyCode() { return getString(CURRENCY_CODE); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy