Reference > Analytics for IBM WebSphere Commerce > Analytics tag library for IBM WebSphere Commerce
Shop cart tag
The shopping cart tag collects information about shopping cart additions and changes, and sends the information to an external analytics system.
The data generated by this tag class for each item in the shopping cart includes:
- Product part number
- Product name
- Quantity
- Base price
- Product category in the catalog the customer is browsing
- Product category in the master catalog
- Currency
- Store identifier
- Any extra parameters for tag customization
WebSphere Commerce provides an abstract base tag implementation class for the shopping cart tag:
This base class collects information about an analytics shopping cart view event. Analytics vendors who want to provide a shopping cart tag in their Web analytics JSP tag library can extend this base tag class to get the shopping cart data and implement their own logic to generate the vendor-specific shopping cart tagging APIs.
Parameters
The shopping cart tag takes the following parameters:
- databean
- An optional parameter that is a populated instance of the OrderDataBean. If this parameter is missing, one will be created if the orderid attribute is not empty.
- orderId
- An optional parameter that is the order ID of the order being displayed. This is ignored if a value is specified using the databean parameter or the orderType parameter.
- includeTaxInUnitPrice
- An optional parameter that is used to conditionally exclude or include the tax along with the unit price sent to the external analytics system. The default value is 'false'. If set to 'true', the unit price sent to the external analytics system is the sum of the unit price and the tax calculated for the particular product.
- extraparmsMap
- An optional parameter that communicates additional information to the external analytics system as necessary. This parameter is useful when additional information needs to be passed with each catalog entry present in the shopping cart. This parameter is different from the extraparms parameter because the values passed as extraparams are appended to all catalog entries present in the shopping cart.
The input to this parameter is a java.util.Map type object in which the key for each entry in the map is the orderItemId. The value for a particular key is the extra parameter passed along with the catalog entry associated with the order item. The value for each orderItemId is appended to the argument list for the analytics tag output of that particular order item.
To pass more than one parameter, separate the values with a comma, as shown in this example:
extraparmsMap="\"field1\", \"field2\""
- extraparms
- An optional parameter that communicates additional information to the external analytics system as necessary. This parameter is provided for cases in which you might have negotiated with the external analytics vendor to generate some custom report that requires additional information. Any information specified as a value for this parameter is appended to the argument list in the analytics tag output and should be properly escaped JavaScript.
To pass more than one parameter, separate values with a comma, as shown in this example:
extraparms="\"field1\", \"field2\""
This parameter also allows you to make a function call within the given data bean, which supports dynamic content. Any parameter using extraparms starting and ending with the $ symbol, for example, $getMethod$, will be assumed to be a method name of the object passed using either of the attributes databean or orderType. The only restriction on the method name is that it must take no arguments and the object returned must implement the toString() method.
- orderType
- An optional parameter that is a populated instance of the com.ibm.commerce.order.facade.datatypes.OrderType object. This parameter can be used if the store JSPs are implemented using WebSphere Commerce services.
Shop cart tag for Coremetrics
WebSphere Commerce provides a default shopping cart tag implementation for Coremetrics. To use this tag, include the tag library in the JSP page. The tag library must be referenced prior to the main page content. Use the following tag so that the JSP page refers to the tag library:
<%@ taglib uri="http://commerce.ibm.com/coremetrics" prefix="cm" %>
The shopping cart tag must be included in the JSP before the page view tag.
Examples:
In most cases, to add the shopping cart tag, you only need to include the following code:
<cm:cart databean="${order_OrderDataBean}" />
or
<cm:cart orderType="${order}" />
If to include the tax in the price sent to Coremetrics, your tag would look like this:
<cm:cart orderType="${order}" includeTaxInUnitPrice="true"/>
XML definition
<tag> <name>cart</name> <tag-class>com.ibm.commerce.bi.taglib.coremetrics.CartTag</tag-class> <body-content>empty</body-content> <description>Sets ShopAction5 tags for shopping cart display pages.</description> <attribute> <name>databean</name> <required>false</required> <rtexprvalue>true</rtexprvalue> <description>Populated instance of com.ibm.commerce.order.beans.OrderDataBean. If missing, one will be created if orderid attribute is not empty.</description> </attribute> <attribute> <name>orderType</name> <required>false</required> <rtexprvalue>true</rtexprvalue> <description>Populated instance of com.ibm.commerce.order.facade.datatypes.OrderType.</description> </attribute> <attribute> <name>orderId</name> <required>false</required> <rtexprvalue>true</rtexprvalue> <description>Order ID of the order being displayed. Will be ignored if a databean or the orderType SDO is given.</description> </attribute> <attribute> <name>includeTaxInUnitPrice</name> <required>false</required> <rtexprvalue>true</rtexprvalue> <description>Include/Exclude Tax in Unit price</description> </attribute> <attribute> <name>extraparms</name> <required>false</required> <rtexprvalue>true</rtexprvalue> <description>Additional fields that will be appended to argument list in the Coremetrics tag output.To pass more than 1 parameter, use an input like extraparms="\"field1\", \"field2\"".</description> </attribute> <attribute> <name>extraparmsMap</name> <required>false</required> <rtexprvalue>true</rtexprvalue> <description>Additional fields that will be appended to the argument list for the items in the shopping cart in the Coremetrics tag output depending on the map's value for that particular item in the cart</description> </attribute> </tag>
Related tasks
Tag the store pages for Coremetrics
Related reference