This reference describes the methods that you use for customizing ecommerce in Google Analytics reporting. For more information on setting up ecommerce tracking, see Ecommerce Tracking under "Setting Up Analytics."
_addItem(orderId, sku,
name, category, price, quantity)_addTrans(orderId,
affiliation, total, tax, shipping, city, state, country)_trackTrans()_addItem(orderId, sku, name, category, price, quantity)
Use this method to track items purchased by visitors to your ecommerce
site. This method tracks individual items by their SKU. This means that
the sku parameter is required.
This method then associates the item to the parent transaction object
via the orderId argument. Arguments for this method are
matched by position, so be sure to supply all parameters, even if some
of them have an empty value.
This method performs no additional calculations, such as quantity calculations. Therefore, you should keep in mind the following best practices:
name parameter is not required, items added to
a transaction without a name parameter do not appear
in the product breakdown for a transaction. While you will still
see the total revenue for the transaction, you will not be able
to see how much revenue a particular item contributed to the transaction
total. pageTracker._addItem(
'1234', // order ID - necessary to associate item with transaction
'DD44', // SKU/code - required
'T-Shirt', // product name - necessary to associate revenue with product
'Olive Medium', // category or variation
'11.99', // unit price - required
'1' // quantity - required
);
String orderId Order ID of the transaction
to associate with item.
String sku Required. Item's
SKU code.
String name Product name. Required to see
data in the product detail report.
String category Product category.
String price Required. Product
price.
String quantity Required. Purchase
quantity.
_addTrans(orderId, affiliation, total, tax, shipping, city, state,
country)
_addItem(),
this method handles only transaction tracking and provides no additional
ecommerce functionality. Therefore, if the transaction is a duplicate of
an existing transaction for that session, the old transaction values are
over-written with the new transaction values. Arguments for this method
are matched by position, so be sure to supply all parameters, even if some
of them have an empty value.
pageTracker._addTrans(
'1234', // order ID - required
'Womens Apparel', // affiliation or store name
'28.28', // total - required
'1.29', // tax
'15.00', // shipping
'San Jose', // city
'California', // state or province
'USA' // country
);
String orderId Required.
Internal unique order id number for this transaction.
String affiliation Partner or store affiliation
(undefined if absent).
String total Required.
Total dollar amount of the transaction.
String tax Tax amount of the transaction.
String shipping Shipping charge for the
transaction.
String city City to associate with transaction.
String state State to associate with transaction.
String country Country to associate with
transaction.
_gat.GA_EComm_.Transactions_ The transaction object
that was created or modified.
_trackTrans()
_trackPageview(), and
used in conjunction with the _addItem() and addTrans() methods.
It should be called after items and transaction elements have been set
up.
var pageTracker = _gat._getTracker('UA-12345-1');
pageTracker._trackPageview();
pageTracker._addTrans(
'1234', // order ID - required
'Womens Apparel', // affiliation or store name
'28.28', // total - required
'1.29', // tax
'15.00', // shipping
'San Jose', // city
'California', // state or province
'USA' // country
);
pageTracker._addItem(
'1234', // order ID - necessary to associate item with transaction
'DD44', // SKU/code - required
'T-Shirt', // product name
'Olive Medium', // category or variation
'11.99', // unit price - required
'1' // quantity - required
);
pageTracker._trackTrans();