Purpose: Used to track the shopping cart.Google AnalystMedium feedbackOrder No.AndOrder amountInformation.
Page: http://www.yoursite.com/flow.php? Step = checkout
Configuration method: For details, see the example and simplified code.
E-commerce code Usage Guide
Reference address: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce? Hl = ZH-CN # General
The basic process of tracking e-commerce with Google Analytics summarizes three methods required to track e-commerce exchanges on your website.
These three methods should be called in order in your shopping cart or e-commerce software.
1:Createa transaction object.Create a transaction object
Usethe
_ Addtrans () method to intialize a transaction object. the transaction object stores all therelated information about a single transaction, such as the order ID, shippingcharges, and billing address. the information in the transaction object isassociated
With its items by means of the Order IDs for the transaction and allitems, which shoshould be the same ID.
Use the _ addtrans () method to initialize a transaction object. This object stores information related to a single exchange, such as the orderid order number, shipping charges freight, and billingaddress billing address. The transaction object information is associated with all items by order IDs order number. Must be the same order number.
2:Add items to the transaction.Add an item (product) in the transaction)
The_addItem()
Method tracks information about each individual item in the user's shoppingcart and Associates
The item with each transaction viaorderId
Field. This method tracks the details about a special item, such as SKU, price, category, and quantity.
The _ additem () method tracks the information of each individual item in the shopping cart and associates it with the same transaction number through the same orderid field. This method is used to track special information, such as SKU number, price, category, and quantity.
3:Submitthe transaction to the analytics servers.Submit the transaction to the analyst Server
The_trackTrans()
Method confirms that a purchase has occurred, and all data that has been builtup
In the transaction object is finalized as a transaction.
_ Tracktrans () method after a purchase is confirmed, all information has been completed in the transaction object and submitted to the server.
Sample Code
Https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce? Hl = ZH-CN # General
Chinese comments of sample code
Add a transaction object
_ Gaq. Push (['_ addtrans ',
'123 ',
// Order ID-required Order Number
'Acme clothing ', // affiliationor store name association or store name (optional) can be null''
'11. 99', // total-required
Amount Required
'1. 29', // tax (not required) can be null''
'5', // shipping freight (not required) can be null''
'San jose', // City (not required) can be null''
'California ', // stateor province (not required) can be null''
'Usa' // country (not required) can be null''
]);
Add each item
// Additem might be called for every item in the shopping cart purchaseEvery item in the vehicle needs to be traversed once.
// Where your ecommerceengine loops through each item in the cart and
// Prints out _ additem foreach
_ Gaq. Push (['_ additem ',
'123 ',
// Order ID-required Order Number
'Dd44 ',
// SKU/code-required SKU is required
'T-shirt', // the product name item name can be null''
'Greenmedium ', // category orvariation item category can be null''
'11. 99', // unit price-required
Price required
'1'
// The quantity of quantity-required is required.
]);
_ Gaq. Push (['_ tracktrans']); // submits transaction to the analyticsservers
Submit traffic to the analyst Server
The code to be added after the e-commerce code is simplified is
_ Gaq. Push (['_ addtrans', $ orderid, $ affiliation, $ sumofgoods.pdf, $ tax, $ shipping.pdf, $ City, $ state, $ country]);
_ Gaq. Push (['_ additem', $ orderid, $ skuid, $ productname, $ productcategory, $ unitprice, $ quanity]);
_ Gaq. Push (['_ tracktrans']);
Note:
1. $ affiliation and $ tax can be set as null values without this item ''.
2. When adding an item, you need to traverse each item in the shopping cart.