Use the shopping cart tag with IBM Digital Analytics
If the site is integrated with IBM Digital Analytics, we can use the default implementation of the <cm:cart /> tag that WebSphere Commerce provides. The <cm:cart /> tag generates the following IBM Digital Analytics tag: cmCreateShopAction5Tag.
Tag placement in store pages
Include the <cm:cart /> tag in the shopping cart page. In the page, place the <cm:cart /> tag before the <cm:pageview /> tag.
We must also include the tag library in the JSP file before the main page content using the following code:
<%@ taglib uri="http://commerce.ibm.com/coremetrics" prefix="cm" %>
The data that the <cm:cart /> tag generates is different depending on which IBM Digital Analytics tag library type the store uses. To see examples, go to one of the following sections in the following topic:
Example of tag usage and output for IBM Digital Data Exchange (DDX)
If the WebSphere Commerce store is integrated with DDX to simplify collecting analytics data, the <cm:cart /> tag generates data into the digitalData JavaScript object that is sent to DDX. DDX can then relay the data to IBM Digital Analytics. The generated data that in this JavaScript object can look like the following output:digitalData.cart.item[0] = { productInfo:{productID: 'MCL008_0802', productName: 'Albini Dark Gray Wool Suit'}, quantity: '1', price: '977.97', currency: 'USD', category:{primaryCategory: '3074457345616676683', virtualCategory: ''}, attributes:{exploreAttributes: '', extraFields: ''}}; cmSetupOther({"cm_currencyCode":"USD"}); {} digitalData.cart.item[1] = { productInfo:{productID: 'CAC024_2401', productName: 'Widescreen LCD Monitor'}, quantity: '1', price: '132.03', currency: 'USD', category:{primaryCategory: '3074457345616676695', virtualCategory: ''}, attributes:{exploreAttributes: '', extraFields: ''}}; cmSetupOther({"cm_currencyCode":"USD"});
For more information about integrating with DDX, see IBM Digital Data Exchange integration.
Examples of tag usage: for the custom IBM Digital Analytics library
The <cm:cart /> tag generates the following IBM Digital Analytics data tag:cmCreateShopAction5Tag(productId, productName, productQuantity, productPrice, categoryId, store_id, currency, masterItemCategory, catIDoverride, attributes)
Example 1:
To pass basic data to IBM Digital Analytics about each item in a customer's shopping cart:
Include tag in your
store page like the following code:If the store uses data beans and URL commands for order runtime functions, use the databean parameter: <cm:cart databean="${order_OrderDataBean}" />
If the store uses web services for order runtime functions, use the orderType parameter:
<cm:cart orderType="${order}" />
Example of IBM Digital Analytics
data tag generated: cmCreateShopAction5Tag("AS-01", "AromaStar Deluxe", "1.0", "71.99", "10124", "10101", "USD", "10124");
Note: The examples in this topic use the simplified syntax for specifying extraparms values. We must specify the values using properly escaped JavaScript:
- Simplified syntax example
- extraparms="value1-_-value2,value3-_-value4"
- Properly escaped JavaScript example
- extraparms="\"value1-_-value2\",\"value3-_-value4\""
If any of your extraparms values are JavaScript variables, see the syntax rules explained in Syntax for passing JavaScript variables as extra parameters.
Example 2:
To pass IBM Digital Analytics Explore attributes to the IBM Digital Analytics cmCreateShopAction5Tag that are the same for all items in the shopping cart, use the extraparms parameter (position 2):
Include tag in your
store page like the following code:If the store uses data beans and URL commands for order runtime functions, use the following parameters: <cm:cart databean="${order_OrderDataBean}" extraparms="null, attr1-_-attr2-_-attr3" />
If the store uses web services for order runtime functions, use the following parameters:
<cm:cart orderType="${order}" extraparms="null, attr1-_-attr2-_-attr3" />
Example of IBM Digital Analytics
data tag generated: cmCreateShopAction5Tag("AS-01", "AromaStar Deluxe", "1.0", "71.99", "10124", "10101", "USD", "10124", null, "attr1-_-attr2-_-attr3");
For details about each parameter in the IBM Digital Analytics data tag, see the documentation that is provided by IBM Digital Analytics.
Related concepts
Passing extra data to IBM Digital Analytics with the extraparms parameter
Comparison of extra parameters for IBM Digital Analytics tags
IBM Digital Analytics JavaScript library types: standard and custom
IBM Digital Analytics, formerly known as Coremetrics Analytics integration with Web 2.0 starter stores
Related reference
Shopping cart tag