Pages

Tuesday, February 15, 2011

Cormetrics data file CDFC


This IS the data file to be uploaded before your tags can be recognized by coremetrics. This is a csv file containing the catalog hierarchy.

It is of the form

<<ClientId>>,<<CategoryId>>,<<CategoryName>>,<<ParentCategoryId>>

For example,

XXXXXXX,101,MEN’S,

Here, XXXX is the client Id allocated by coremetrics (Every client has a unique one).
101 is the category Id
And MEN’s is the category name

If there is a subcategory inside MEN’s called “Men’s Shirts” then it is included in the CDF file as
XXXXXXX,101,MEN’S SHIRTS,101

If there are commas in your category, like MEN’s, WOMEN’s then include this in double quotes like below
XXXXXXX,101,”MEN’S,WOMEN’S”

Thursday, February 10, 2011

Creating a coremetrics Shopping Cart View in websphere commerce

This tag is included in your shopping cart to track customers coming on the cart page. The function to be used is cmCreateShopAction5Tag. This tag will be looped for as many numbers of items in the cart. The following are the parameters to be passed to this tag

productId – This is the productId (either the SKU ID or the catentry ID). Please ensure that the productID should be the same as selected in cmCreateProductViewTag(),  otherwise the metrics will be skewed.

Name  - this is the name of the product. Again ensure that the name here matches with the one in the cmCreateProductViewTag().

Quantity – specifies the number of item ordered

Price – this is the unit price of the specified item.

Currency – self explanatory.

Category – This is the category Id to which the product belongs to. In some cases where other systems are used for navigation, like endeca, the category id on product detail may not match the wcs category id. In such cases, setting the category id to null will inherit the category from the previous product view tag.

Monday, February 7, 2011

Coremetrics tags in Websphere Commerce

What you need (For all coremetrics tags) :

1.       Coremetrics Client Id – This is the unique id assigned to your company

2.       Coremetrics data collection domain – Domains are defined for data collection. For example testdata.coremetrics.com is for collecting test data. Please ask coremetrics about your data domain.

3.       Coremetrics Domain – This usually is your Company’s domain name like XXXXXX.com


Creating a coremetrics pageView tag in websphere commerce

The javascript function is cmCreatePageviewTag()
The parameters to be passed to this tag are

1.       Pagename: Specify the page name. Uses html page title automatically if not provided. This is optional

2.       Category: specifies the category of the page. If not provided then nothing is sent to coremetrics.

3.       searchTerms: if it is a search results page, then specifies the search terms. Required parameter for a search results page

4.       searchCount: specifies the total number of results returned by the search

5.       StoreId: is the wcs store Id. If not specified then it looks for storeId parameter in the URL


Eg:

Include couple of java scripts at the end of the page where pagview tag is to be placed


<script language="JavaScript1.1" type="text/JavaScript" src="//libs.coremetrics.com/eluminate.js"></script>

<script language="JavaScript1.1" type="text/JavaScript" src="/wcsstore/coremetrics/cmcustom.js"></script>



Set the coremetrics required parameters like client id, domain etc.


<script language="JavaScript1.1" type="text/JavaScript">
<!--                     
cmSetClientID("<%=MyConfig.getConfigValue(COREMETRICS_CLIENTID)%>",                                    "<%=MyConfig.getConfigValue(COREMETRICS_DATA_COLLECTION_DOMAIN)%>",                         "<%=MyConfig.getConfigValue(COREMETRICS_DOMAIN)%>");
//-->

</script>

<script language="JavaScript1.1" type="text/JavaScript">
<!--
cmCreatePageviewTag("Page Name", null, null, null, "${WCParam.storeId}");
//-->                                                          
</script>


Where “Page Name” is the name of the page and if left blank will be populated with HTML page title. Store ID can be fetched from the WCParam parameter.

Creating a coremetrics productView tag in websphere commerce

This tag is included on the product detail page to capture product views in the coremetrics reports

The function used is cmCreateProductviewTag(). This tag is included on the product detail page to capture product views in the coremetrics reports

Parameters that needs to be passed to this tag are:

ProductId: Include either the catentry_Id here or the partnumber (SKU Id) as per the requirements. It generally is partnumber. This is a mandatory field

Name: include the product name. This is a mandatory field

categoryId: include the category Id to which this product belongs to. If you are using endeca for navigation, the category id of endeca might not match with what is in WCS. Hence, you need to include the correct categoryId here depending on what you have in your Coremetrics Data File (CDF) that was supplied to coremetrics initially. The CDF file contains the list of category mappings (hierarchy).

storied – this is the store id of wcs. Use WCParam to get the store Id


More on cart view tags (cmCreateShopAction5) in next blog

Wednesday, February 2, 2011

Creating your own Registry


Create a custom registry to manage the custom configuration properties file in websphere commerce.

Create a custom class called ApplicationRegistry. This class will be responsible for loading and refreshing your custom configuration property file. This class will implement com.ibm.commerce.registry.Registry interface.

public class ApplicationRegistry implements Registry {       
       /**
        * Name of the applicattion configuration file
        */                                                                         
       public final static String PROPERTIES_FILE = "xxx_configuration.properties";
/**
        * Name of the Registry used for custom application configuration
        */
       public final static String REGISTRY_NAME = "ApplicationRegistry";

Implement Initialize () method of Registry interface and register this custom registry with wcs app as shown below.
/**
        * @see com.ibm.commerce.registry.Registry#initialize()
        */
       public void initialize() throws Exception {
              final String METHOD = "initialize";
Properties prop = new Properties();
              try {
                  prop.load(getInputStream(filename));
              } catch (Exception e) {
                  throw new ECSystemException(ECMessage._ERR_GENERIC,CLASSNAME,e.getMessage());
              }//end try          
WcsApp.registerObject(REGISTRY_NAME, this);

       }

In the initialize method, read the file and populate it to a Properties Object.  Also, register this registry with the websphere commerce application using WcsApp.registerObject(“Registry_Name”, this)

Implement the refresh method of the Registry interface. This method should take care of the refresh registry command issued from Websphere Administration Console.

public void refresh() throws Exception {
              final String METHOD = "refresh";
              ECTrace.entry(ECTraceIdentifiers.COMPONENT_EXTERN, CLASSNAME, METHOD);
                          
              readConfiguration();
              // intializeProfileProperties();
              // initializeRegionCodes();
             
              observable.refresh(this);
              ECTrace.exit(ECTraceIdentifiers.COMPONENT_EXTERN, CLASSNAME, METHOD);
       }

private class RegObservable extends Observable{
           public void refresh(Object object){
               setChanged(); //properties changed
               notifyObservers(object); //notify observers
           }
       };
       private RegObservable observable = new RegObservable ();

The refresh method uses the observer pattern. In the above code, there is a class RegObservable which extends Observable and implements refresh method.
Once your own ApplicationRegistry is created, you need to register the registry in wc-server.xml.
<Registries>
......
......
.....

<registry
      name="ApplicationRegistry" regClassName="com.tgg.commerce.registry.ApplicationRegistry"/>
</Registries>

Now create a custom configuration property file in WC_ToolkitPath/properties  or in WC_profile.ear/properties file (in case of wc_server)