Customer Events

Customer Events are events triggered by customer actions and are persisted in the database. Each event contains the id of the customer, the date, the event action (to distinguish between different types of events), the store id and optionally any data related to the event such as the product or customer id.

For example, events allow you to track:

The number of events generated by KonaKart is determined by the number of visitors to your store and by how much tracking information you wish to gather. So as not to impact run time performance, the events may be written to a different database rather than to the production database. Also, the KonaKart event manager contains a buffer that receives events from the storefront application and immediately returns control. The buffer is emptied in the background by a separate thread.

Creating Customer Events

The KonaKart application API contains an insertCustomerEvent(CustomerEventIf event) API call that may be used to insert events. The Struts action classes of the KonaKart storefront application by default insert a certain number of events if these are enabled in the Configuration >> Customer Details section of the admin app.

The event actions are defined in BaseAction.java.


    /*
     * Event actions
     */
    protected static final int ACTION_NEW_CUSTOMER_VISIT = 1;

    protected static final int ACTION_CUSTOMER_LOGIN = 2;

    protected static final int ACTION_ENTER_CHECKOUT = 3;

    protected static final int ACTION_CONFIRM_ORDER = 4;

    protected static final int ACTION_PAYMENT_METHOD_SELECTED = 5;

    protected static final int ACTION_REMOVE_FROM_CART = 6;

    protected static final int ACTION_PRODUCT_VIEWED = 7;
               

You may define new actions to insert events for your particular requirements. BaseAction.java also contains helper methods (insertCustomerEvent()) for inserting the events.

Examples of how to use the insertCustomerEvent() method may be found in various struts action classes. For example, to track products being removed from the cart:


    insertCustomerEvent(kkAppEng, ACTION_REMOVE_FROM_CART, b.getProductId());
               

konakart.properties contains the definition of the database connection for the database where the events are written. By default the installer sets it to the production database.


# Enterprise Feature
torque.database.kkstats.adapter              = mysql
torque.dsfactory.kkstats.connection.driver   = com.mysql.jdbc.Driver
torque.dsfactory.kkstats.connection.url      = jdbc:mysql://localhost:3306/dbname
                                 ?zeroDateTimeBehavior=convertToNull&useSSL=false
torque.dsfactory.kkstats.connection.user     = root
torque.dsfactory.kkstats.connection.password =