IBM WebSphere Commerce Version 7 provides an out-of-box integration between the WebSphere Commerce store and IBM Coremetrics, the preferred cross-channel analytics service provider for WebSphere Commerce. The integration provides the following features:
- A custom JSTL for WebSphere Commerce, which acts as a wrapper for generating the Coremetrics analytics JavaScript tags
- A Dojo-based analytics store tagging framework for the Web 2.0 store, where Coremetrics tags are triggered based on asynchronous events
- A JavaScript library to support the display of dynamic Intelligent Offer recommendations from Coremetrics
- Integration of the Coremetrics dashboard and reports with the IBM WebSphere Commerce Management Center UI using single sign-on
This article explains how to pass custom data to Coremetrics accounts by customizing the out-of-box JSTL.
Coremetrics for WebSphere Commerce provides a custom JSTL for generating the Coremetrics JavaScript tags. These JSTL tags are placed in the respective store pages to generate the Coremetrics tagging required for the page. For more information about the JSTL tags for Coremetrics integration, go to "Analytics tag library for IBM WebSphere Commerce" in the WebSphere Commerce Version 7.0 Knowledge Center (see Resources).
The data generated out of the box by these tags usually satisfies your needs. In some cases, you
might want to pass values for one or more parameters that are different from the default values. For
example, the Coremetrics JSTL cart tag and order tag pass the discounted price of a product in the unit price parameter of the
Coremetrics cmCreateShopAction5Tag() tag and the cmCreateShopAction9Tag() tag, by default. If you want to pass the nondiscounted price in
these parameters instead of the default discounted price, you can customize the WebSphere Commerce
JSTL for Coremetrics.
The WebSphere Commerce JSTL for Coremetrics acts as a wrapper for the Coremetrics JavaScript tags. These JSTL tags generally take the ID of an object, a databean, or a SDO object as input and generate the appropriate Coremetrics JavaScript tags. Every JSTL tag class for Coremetrics integration has a generic base tag class and an implementation class. The generic base tag class gathers the data that is needed to generate the Coremetrics JavaScript tag. The implementation tag class extends the generic base tag class and formats the data based on the analytics vendor's requirements. These tag classes use the data to generate the Coremetrics JavaScript tags and write those generated tags to the HTML output stream.
Table 1 shows the WebSphere Commerce analytics tags and the corresponding Coremetrics implementation tag classes. The table also shows the methods that must be overwritten to customize the analytics data that is passed to Coremetrics.
Table 1. WebSphere Commerce analytics tags and the corresponding Coremetrics implementation tag classes
|
Analytics Tag |
Generic Base Tag Class |
Coremetrics Implementation Class | Method(s) to overwrite |
|---|---|---|---|
| pageview |
com.ibm.commerce.bi.taglib. CommonBaseTag | com.ibm.commerce.bi.taglib. coremetrics.CommonTag | public HashMap<String, Object> getParamMap() |
| registration |
com.ibm.commerce.bi.taglib. MembershipBaseTag | com.ibm.commerce.bi.taglib. coremetrics.RegistrationTag | public HashMap<String, Object> getParamMap() |
| element |
com.ibm.commerce.bi.taglib. ElementBaseTag | com.ibm.commerce.bi.taglib. coremetrics.ElementTag | public HashMap<String, Object> getParamMap() |
| conversion |
com.ibm.commerce.bi.taglib. ConversionBaseTag | com.ibm.commerce.bi.taglib. coremetrics.ConversionTag | public HashMap<String, Object> getParamMap() |
| product |
com.ibm.commerce.bi.taglib. ProductBaseTag | com.ibm.commerce.bi.taglib. coremetrics.ProductTag | public Vector<HashMap <String, Object>> getParamVector() |
| order |
com.ibm.commerce.bi.taglib. OrderBaseTag | com.ibm.commerce.bi.taglib. coremetrics.OrderTag |
|
| cart |
com.ibm.commerce.bi.taglib. CartBaseTag | com.ibm.commerce.bi.taglib. coremetrics.CartTag | public Vector<HashMap<String, Object>> getParamVector() |
| campurl |
com.ibm.commerce.bi.taglib. CampaignBaseTag | com.ibm.commerce.bi.taglib. coremetrics.CampaignURLTag | public HashMap<String, Object> getParamMap() |
The abstract base tag class stores the data in either a java.util.HashMap object or in a java.util.Vector
object. For example, because the pageview tag requires a minimal amount
of data, the CommonBaseTag class stores the data for analytics in a
HashMap object. However, the CartBaseTag class must pass data on all
order items in the shopping cart. For this reason, the CartBaseTag class
uses a Vector to store the analytics data. The individual cart item details are inside a HashMap.
The details of the structure of the HashMap object and the keys used in the map are listed in the
javadoc for each base tag class.
Example: Customize the order tag to pass nondiscounted price to Coremetrics
This example shows how to pass the nondiscounted price of a product in the shopping cart to
Coremetrics. Out-of-the-box, the order tag uses the discounted price of a
product when generating the individual cmCreateShopAction9Tag(...) tags
for each item in the shopping cart. The order tag also uses the
discounted product price to calculate the order subtotal for the entire order when generating the
cmCreateOrderTag(...) function. To pass the nondiscounted price, you must
extend the data used to generate both JavaScript tags.
To customize the data, perform these tasks:
- Create a new custom JSTL tag class that extends the
com.ibm.commerce.bi.taglib.coremetrics.OrderTagclass. See Listing 1 for a sample of theSkeletonclass code.
Listing 1. Skeleton class
packagecom.ibm.mycompany.bi.taglib.coremetrics;
importcom.ibm.commerce.bi.taglib.coremetrics.OrderTag;
publicclassExtOrderTagextendsOrderTag {
}
- Overwrite the two methods that generate data for
cmCreateOrderTag(...)andcmCreateShopAction9Tag(...).ThegetOrderParamMap()method generates data forcmCreateOrderTag(...)and thegetOrderItemsParamVector()method generates data forcmCreateShopAction9Tag(...). See Listing 2 for a sample of the extendedOrderTagclass code.
- Create a new tag library descriptor for the custom tag and tag class. Ensure that the descriptor
contains the new custom tag name and the tag class mapping. See Listing
3 for a sample of the a tag library descriptor code.
To get the attribute list for the out-of-the-box order tag, refer to the coremetrics.tld file inside the Stores.war/WEB-INF directory.
- Update the store page to use the custom descriptor and the custom order tag.
Refer the custom tag library descriptor, as shown here:<%@ taglib uri="http://commerce.ibm.com/coremetrics-ext" prefix="cm-ext" %>.Update the tagging for order to use the custom order tag, as shown here:<cm-ext:order orderType="..." />
You can pass custom analytics data to Coremetrics by overwriting the default methods that are provided by WebSphere Commerce JSTL.
Learn
- "Analytics tag library for IBM WebSphere Commerce" in the WebSphere Commerce Version 7.0
Information Center provides more information about the IBM WebSphere Commerce tag library for
analytics.
- In the Commerce Zone, get information about other Commerce resources.
- Stay current with developerWorks technical
events and webcasts focused on a variety of IBM products and IT industry topics.
- Attend a free developerWorks Live!
briefing to get up-to-speed quickly on IBM products and tools as well as IT industry trends.
- Follow developerWorks on Twitter.
- Watch developerWorks on-demand demos ranging
from product installation and setup demos for beginners, to advanced functionality for experienced
developers.
Get products and technologies
-
Evaluate IBM products in the way that
suits you best: Download a product trial, try a product online, use a product in a cloud
environment, or spend a few hours in the SOA Sandbox learning
how to implement Service Oriented Architecture efficiently.
Discuss
- Get involved in the My developerWorks community. Connect with
other developerWorks users while exploring the developer-driven blogs, forums, groups, and wikis.



