Using the AquaLogic Interaction Analytics 2.0 OpenUsage API
Pages: 1, 2, 3, 4, 5

Step 4: Configure and Launch Analytics

You must configure Analytics to store events from custom applications by modifying the and openusage.xml files. The instructions below are simplified for example purposes only. For a list of ports used by Analytics and details on configuring the Analytics database, see the Installation and Upgrade Guide for BEA AquaLogic Interaction Analytics.

  1. Enter the Analytics server port in openusage.xml:

  1. Enter database information for the Analytics Server in the file. (Use the appropriate driver and URL for your configuration.)



  1. Place both configuration files in the appropriate config location. You can place the openusage.xml file anywhere, but your code must reference this file when initializing OpenUsage. This is done by calling the following method, where configDirectory is the path to the folder where openusage.xml is located. (This method only needs to be called once during your application run, normally during startup).

    ASEventFactory.setConfig("configDirectory", "openusage.xml");

    In the sample application, the OpenUsageDemoServlet class calls setConfig in the init() method. The configDirectory parameter is defined in web.xml as .\openusage-demo\config\settings. To change this location, open the .war file and modify the configDirectory init-param in web.xml.

  2. Deploy the application .war file to any Java Servlet Container.
  3. On the Analytics server box, make sure the Analytics Collector Service is started.

Step 5: Query Analytics and Display Statistics

Analytics includes a collection of standard reports that display portal events; for details, see the Administrator Guide for BEA AquaLogic Interaction Analytics. To retrieve data from the Analytics database for custom reports, use SQL. To define or determine table and column names, see the Event Registration page of Analytics Administration (see Step 2: Register and Configure Events in Analytics Administration on page 3). For descriptions of the tables that are delivered with Analytics, see the AquaLogic Interaction Analytics Database Schema in the product documentation.

In this sample application, the "View Events!" button opens a JSP page with a pie chart that shows the percentage of clicks by page name, as shown in Figure 5, or the event method, as shown in Figure 6.

Figure 5
Figure 5. Results grouped by page name

Figure 6
Figure 6. Results grouped by method name

The query to the Analytics database is handled in the same servlet that raises the Go to My Demo Page! event.


* View "demo event" data using JFreeCharts and cewolf tag libraries.


* @param req HttpServletRequest

* @param res HttpServletResponse


public void viewEvents(HttpServletRequest req, HttpServletResponse res) 

throws IOException, ServletException {

try {

Connection conn = getDatabaseConnection();

Statement stmt = conn.createStatement();

String query = "";

if ("EVENT_METHOD".equals(req.getParameter("groupby"))) {

// group by eventMethod

query = "select count(*), method.value " + "from ascfact_demo_event fact, ascdim_page_name page, ascdim_event_method

method " + "where fact.page_name = and fact.event_method = " + "group by method.value";

req.getSession().setAttribute("GROUP_BY_CHECKED", "EVENT_METHOD"); 

} else {

// group by pageName

query = "select count(*), page.value " + "from ascfact_demo_event fact, ascdim_page_name page, ascdim_event_method

method " + "where fact.page_name = and fact.event_method = " + "group by page.value";

req.getSession().setAttribute("GROUP_BY_CHECKED", "PAGE_NAME"); 


// execute the query

ResultSet results = stmt.executeQuery(query);

// create a JFreeChart DatasetProducer which will be rendered by the cewolf tag library

DatasetProducer datasource = new PieChartDatasetProducer(results);

req.setAttribute("datasource", datasource);

// close database resources




} catch (Exception e) {


throw new ServletException("Exception while creating DatasetProducer - " + e);


RequestDispatcher dis = req.getRequestDispatcher("demo_chart.jsp"); 

dis.forward(req, res);


The sample application uses a JFreeCharts dataset producer to iterate over the data. The JSP page that displays the pie charts uses cewolf tags to render the data from the JFreeCharts dataset producer. To view the code for these components, see the and demo_chart.jsp files in the sample download.


Download the OpenUsage demo application files from Dev2Dev: OpenUsage sample application.


BEA AquaLogic Interaction Analytics allows you to track activity and usage to ensure that users are finding the resources they need. The Analytics OpenUsage API provides a variety of ways to raise custom events in your portal and Web applications to be stored in the Analytics database.

Jennifer Shipman is a staff technical writer in the BEA AquaLogic Interaction product team. She has been the lead writer for ALUI developer tools for more than 5 years.