Reporting on a Custom Commerce Event
A report for commerce events can be created through Commerce Server Business Desk by using a new cube or an SQL query. But before you can create reports for the new commerce event, you must have wishlist event data in your log files to import into the Data Warehouse. The process of adding the wish list user interface and updating ASP pages is left to the user. If you have not added the wish list functionality to your Web site, you can use the sample log files included in the procedures to see how the process will work when your site has wish list functionality in place for users.
Important
- We recommend that you do not develop a production-quality site based on the Retail2002 Site. We recommend that you use the Commerce Server 2002 Starter Site to develop a production quality site. You can download the Starter Site from https://go.microsoft.com/fwlink/?linkid=37800.
To generate sample log file data for the Retail Solution Site
To generate sample log file data for the Retail2002 - International Retail Site
To make the current log file available for reports
To create a Custom Commerce Event report based on an SQL query
To create a Custom Commerce Event report based on an OLAP cube
Note
- If you are using the Retail2002 site, or if your site is based on ASP.NET, skip to the To generate sample log file data for the Retail2002 – International Retail Site topic.
To generate sample log file data for the Retail Solution Site
Click Start, point to Programs, point to Accessories, and then click Notepad.
In Notepad, paste the following code:
<% 'An array of Commerce Events to log. g_rgEvents = Array( _ "CEVT={T=WISH,EVT=ADDTOLIST,PRID=""Bike"",QTY=""1"",LN=""Wife""}", _ "CEVT={T=WISH,EVT=ADDTOLIST,PRID=""HolidayCD"",QTY=""1""," + _ "LN=""Holidays""}", _ "CEVT={T=WISH,EVT=ADDTOLIST,PRID=""Printer"",QTY=""1""," + _ "LN=""Wife""}", _ "CEVT={T=WISH,EVT=DROPFROMLIST,PRID=""Printer"",QTY=""1""," + _ "LN=""Wife""}", _ "CEVT={T=WISH,EVT=ADDTOLIST,PRID=""JazzCD"",QTY=""1""," + _ "LN=""Brother""}", _ "CEVT={T=WISH,EVT=DROPFROMLIST,PRID=""StonewashedJeans""," + _ "QTY=""1"",LN=""Kid""}" _ ) 'Determine if the request involves adding a new event to the log file If (Not vbNullString = Request.QueryString("Event")) Then sEventID = CLng(Request.QueryString("Event")) 'Make sure the requested event is available If (Not sEventID > UBound(g_rgEvents)) Then 'Log the event Call Response.AppendToLog("&") Call Response.AppendToLog(g_rgEvents(sEventID)) 'Get the event data to display on the page sEventData = g_rgEvents(sEventID) End If End If %> <html> <head> <title>Extending Commerce Events</title> </head> <body> <% 'Dynamically render a collection of links for logging different 'Commerce Events to the IIS log file. Note that this is required 'because each call to Response.AppendToLog() will only log the data on 'a single line associated with the current GET request. For itr = 0 to UBound(g_rgEvents) Call Response.Write("<a href=""SampleEventData.asp?Event=" _ & CStr(itr) & """>Log Commerce Event " & CStr(itr) & "</a><br/>") Next %> Commerce Event logged: <b><%= sEventData %></b> </body> </html>
On the File menu, click Save As.
In the Save As dialog box, in the Save In box, navigate to the root drive of your Web site, for example C:/Inetpub/wwwroot/retail, type SampleEventData.asp, and then click Save.
On the File menu, click Exit.
Click Start, point to Programs, and then click Internet Explorer.
Navigate to the SampleEventData.asp page, for example, https://localhost/retail/SampleEventData.asp.
To add each event to the log file, click each Log Commerce Event link on the page. Add as many events to the log file as you want. Adding more events to the log file means there will be more events to report on later. You can add multiple instances of the same event.
To view the log file in which the event information was stored, open the log file for the appropriate day from the log file directory, for example, C:\WINNT\system32\LogFiles\W3SVC1.
To close Internet Explorer, on the File menu, click Close.
Note
- If you are using the Retail Solution Site, or if your site is based on ASP and not ASP.NET, skip to the To make the current log file available for reports topic.
To generate sample log file data for the Retail2002 - International Retail Site
Click Start, point to Programs, point to Microsoft Visual Studio .NET, and then click Microsoft Visual Studio .NET.
In Visual Studio .NET, on the File menu, point to Open, and then click Projects.
In the Open Project dialog box, navigate to <drive>:/Inetput/wwwroot/retail2002, select Retail2002.sln, and then click Open.
The Retail2002 site opens in the Visual Studio .NET window.
On the Project menu, click Add New Item.
In the Add New Item – Retail2002 dialog box, in the Templates section, select Class, type Wishlist.vb in the Name window, and then click Open.
On the Edit menu, click Select All, and then press the Delete key.
Paste the following code into the Wishlist.vb page:
Imports Microsoft.CommerceServer.Runtime <CommerceEvent("WISH")> _ Public Class MyWishListEvent : Inherits BaseCommerceEvent ' Visual Basic .NET is case insensitive, ' so you must make these names unique ' from the public property names Private _myCustomValue As String Private _myPRID As String Private _myQTY As String Private _myLN As String Private _myEvent As String 'Constructor Public Sub New(ByVal customValue As String) _myCustomValue = customValue End Sub 'Body of BaseCommerceEvent.Validate() method Public Overrides Function Validate() As Boolean 'noop validation Return True End Function 'Define event properties <CommerceEventMember("EVT")> _ Public Property MyEvent() As String Get Return _myEvent End Get Set(ByVal value As String) _myEvent = value End Set End Property <CommerceEventMember("PRID")> _ Public Property MyPRID() As String Get Return _myPRID End Get Set(ByVal value As String) _myPRID = value End Set End Property <CommerceEventMember("QTY")> _ Public Property MyQTY() As String Get Return _myQTY End Get Set(ByVal value As String) _myQTY = value End Set End Property <CommerceEventMember("LN")> _ Public Property MyLN() As String Get Return _myLN End Get Set(ByVal value As String) _myLN = value End Set End Property End Class
On the Project menu, click Add New Item.
In the Add New Item-Retail2002 dialog box, do the following: In the Add New Item – Retail2002 dialog box, in the Templates section, select WebForm, type Wishlist.aspx in the Name window, and then click Open.
On the View menu, click HTML Source.
On the Edit menu, click Select All, and then press the Delete key.
Paste the following code into the Wishlist.aspx HTML page:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Wishlist.aspx.vb" Inherits="Microsoft.CommerceServer.Site.Wishlist"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>Wishlist</title> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0"> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="https://schemas.microsoft.com/intellisense/ie3-2nav3-0"> </HEAD> <body MS_POSITIONING="GridLayout"> <TABLE height="297" cellSpacing="0" cellPadding="0" width="266" border="0" ms_2d_layout="TRUE"> <TR vAlign="top"> <TD width="266" height="297"> <FORM id="Form1" method="post" > <TABLE height="249" cellSpacing="0" cellPadding="0" width="285" border="0" ms_2d_layout="TRUE"> <TR vAlign="top"> <TD width="56" height="32"></TD> <TD width="160"></TD> <TD width="69"></TD> </TR> <TR vAlign="top"> <TD height="32"></TD> <TD colSpan="2"> <asp:Button id="Button1" Text="Log Commerce Event 0"></asp:Button></TD> </TR> <TR vAlign="top"> <TD height="32"></TD> <TD colSpan="2"> <asp:Button id="Button2" Text="Log Commerce Event 1"></asp:Button></TD> </TR> <TR vAlign="top"> <TD height="32"></TD> <TD colSpan="2"> <asp:Button id="Button3" Text="Log Commerce Event 2"></asp:Button></TD> </TR> <TR vAlign="top"> <TD height="32"></TD> <TD colSpan="2"> <asp:Button id="Button4" Text="Log Commerce Event 3"></asp:Button></TD> </TR> <TR vAlign="top"> <TD height="32"></TD> <TD colSpan="2"> <asp:Button id="Button5" Text="Log Commerce Event 4"></asp:Button></TD> </TR> <TR vAlign="top"> <TD height="40"></TD> <TD colSpan="2"> <asp:Button id="Button6" Text="Log Commerce Event 5"></asp:Button></TD> </TR> <TR vAlign="top"> <TD height="17"></TD> <TD> <asp:Label id="Label1" Font-Size="Smaller" Font-Names="Arial">Commerce Event logged:</asp:Label></TD> </TR> <TR vAlign="top"> <TD height="17"></TD> <TD> <asp:Label id="EventData" Font-Names="Arial" Font-Size="Smaller"></asp:Label></TD> </TR> </TABLE> </FORM> </TD> </TR> </TABLE> </body> </HTML>
In Solution Explorer, click .
In Solution Explorer, expand Wishlist.aspx, and then double-click the code-behind page, Wishlist.aspx.vb.
On the Edit menu, click Select All, and then press the Delete key.
Paste the following code into the Wishlist.aspx.vb page:
Imports Microsoft.CommerceServer.Runtime Public Class Wishlist Inherits System.Web.UI.Page Protected WithEvents Label1 As System.Web.UI.WebControls.Label Protected WithEvents Button1 As System.Web.UI.WebControls.Button Protected WithEvents Button3 As System.Web.UI.WebControls.Button Protected WithEvents Button4 As System.Web.UI.WebControls.Button Protected WithEvents Button5 As System.Web.UI.WebControls.Button Protected WithEvents Button6 As System.Web.UI.WebControls.Button Protected WithEvents EventData As System.Web.UI.WebControls.Label Protected WithEvents Button2 As System.Web.UI.WebControls.Button #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Create an instance of the new Commerce Event class Dim cevt As MyWishListEvent cevt = New MyWishListEvent("My Wishlist Event") 'Set event data cevt.MyEvent = "ADDTOLIST" cevt.MyPRID = "Bike" cevt.MyQTY = "1" cevt.MyLN = "Wife" 'Log event data CommerceContext.LogCommerceEvent(cevt) 'Output event data to the page EventData.Text = cevt.ToString() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim cevt As MyWishListEvent cevt = New MyWishListEvent("My Wishlist Event") cevt.MyEvent = "ADDTOLIST" cevt.MyPRID = "HolidayCD" cevt.MyQTY = "1" cevt.MyLN = "Holidays" CommerceContext.LogCommerceEvent(cevt) EventData.Text = cevt.ToString() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim cevt As MyWishListEvent cevt = New MyWishListEvent("My Wishlist Event") cevt.MyEvent = "ADDTOLIST" cevt.MyPRID = "Printer" cevt.MyQTY = "1" cevt.MyLN = "Wife" CommerceContext.LogCommerceEvent(cevt) EventData.Text = cevt.ToString() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim cevt As MyWishListEvent cevt = New MyWishListEvent("My Wishlist Event") cevt.MyEvent = "DROPFROMLIST" cevt.MyPRID = "Printer" cevt.MyQTY = "1" cevt.MyLN = "Wife" CommerceContext.LogCommerceEvent(cevt) EventData.Text = cevt.ToString() End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Dim cevt As MyWishListEvent cevt = New MyWishListEvent("My Wishlist Event") cevt.MyEvent = "ADDTOLIST" cevt.MyPRID = "JazzCD" cevt.MyQTY = "1" cevt.MyLN = "Brother" CommerceContext.LogCommerceEvent(cevt) EventData.Text = cevt.ToString() End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim cevt As MyWishListEvent cevt = New MyWishListEvent("My Wishlist Event") cevt.MyEvent = "DROPFROMLIST" cevt.MyPRID = "Stonewashed Jeans" cevt.MyQTY = "1" cevt.MyLN = "Kid" CommerceContext.LogCommerceEvent(cevt) EventData.Text = cevt.ToString() End Sub End Class
In Solution Explorer, double click Web.config.
Update the Commerce Event section with your new class information. Replace the contents of the Commerce Event section with the following code. Notice that the following code contains the fully-qualified assembly name for the first three entries, the original code did not:
<commerceEvent> <add className="Microsoft.CommerceServer.Runtime.AddItemToBasketEvent, Microsoft.CommerceServer.Runtime, Version=4.5.2002.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" loggingEnabled="true"/> <add className="Microsoft.CommerceServer.Runtime.RemoveItemFromBasketEvent, Microsoft.CommerceServer.Runtime, Version=4.5.2002.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" loggingEnabled="true"/> <add className="Microsoft.CommerceServer.Runtime.SubmitOrderEvent, Microsoft.CommerceServer.Runtime, Version=4.5.2002.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" loggingEnabled="true"/> <add className="Microsoft.CommerceServer.Site.MyWishListEvent, Microsoft.CommerceServer.Retail2002" loggingEnabled="true" /> </commerceEvent>
On the Build menu, click Build Solution.
The build process may take a few minutes. The build process is complete when the following message appears on the Output tab:
---------------------- Done ---------------------- Build: 10 succeeded, 0 failed, 0 skipped
To close Visual Studio .NET, on the File menu, click Exit.
After the project is built, click Start, point to Programs, and then click Internet Explorer.
Navigate to the SampleEventData.asp page, for example, https://localhost/retail2002/Wishlist.aspx.
To add each event to the log file, click each Log Commerce Event button on the page. Add as many events to the log file as you want. Adding more events to the log file means there will be more events to report on later. You can add multiple instances of the same event.
To view the log file in which the event information was stored, open the log file for the appropriate day from the log file directory, for example, C:\WINNT\system32\LogFiles\W3SVC1.
To close Internet Explorer, on the File menu, click Close.
To make the current log file available for reports
- You must stop and restart IIS to make the current log file available for reporting. For more information about stopping and restarting IIS, see To restart IIS using Net Stop and Net Start.
Notes
- Before creating a new report, you must run the Configuration synchronization Data Transformation Services (DTS) task, the Web server log import DTS task, and the Report preparation DTS task. For more information about running these DTS tasks, see Running the Configuration Synchronization DTS Task, Running the Web Server Log Import DTS Task, and Running the Report Preparation DTS Task, respectively.
- All World Wide Web Consortium (W3C) log files are logged in Greenwich Mean Time (GMT), and the correction for your time zone occurs when the Web server log import DTS task is run. When running the Web server log import DTS task to import the sample event data, you will need to use the Logs by date/time range option to select the log file for the following day if the time zone for your server is not within the same day as the current time in GMT. For example, if the current time for your server is 8:00 pm on 3/1/2002, and the time in GMT is 2:00 am on 3/2/2002, the sample event data appears in the 3/2/2002 log file.
- Before you can create a Custom Commerce Event report based on an SQL Query, you must ensure that your sample data was successfully imported into the Wishlist01 table of the Data Warehouse.
To create a Custom Commerce Event report based on an SQL Query
Open the Business Desk for the site.
In Business Desk, click Analysis, and then click Reports.
Click on the report toolbar to create your new report.
In the Create a new report - Web Page Dialog screen, do the following:
Use this To do this Report Type Select SQL. SQL Query Type Select * from wishlist01. Note
- If the PivotTable Field List does not appear automatically when you open the table, click on the PivotTable toolbar to view the PivotTable Field List.
Drag ProductNameCat from the PivotTable Field List and drop it into the Drop Row Fields Here box on the PivotTable.
Drag Event from the PivotTable Field List and drop it into the Drop Column Fields Here box on the PivotTable.
Select the Event column, click on the PivotTable toolbar, and then select Count from the drop-down list.
The total number of events for each product appears in the Grand Total column in the PivotTable.
On the PivotTable, click .
The total number of times each product was added and deleted from the list appears in the addtolist and dropfromlist columns.
Click on the toolbar to view the chart.
The chart for the data appears below the pivot table.
In the New Report screen, click on the toolbar.
In the Save a report—Web Page Dialog screen, do the following:
Use this To do this Report Name Type the name of the new report. Report Category Type the report category. Report Description Type a description for the new report. Report Long Description Optional. Type a longer description for the report. This description will be visible in the browser window above the PivotTable controls when you click above the PivotTable controls. Click OK.
Important
When you save a new report, you are saving the report definition, not the data. The next time you run the report, it will have the same rows, columns, and filters, and current data will be queried from Microsoft SQL Server 2000 as specified in the report definition.
On the File menu, click Close.
Note
- For more information about working with PivotTables, click on the PivotTable toolbar.
To create a Custom Commerce Event report based on an OLAP cube
Click Start, point to Programs, point to Administrative Tools, and then click Commerce Server Manager.
In Commerce Server Manager, expand the Analysis Servers node, expand the node for the local server, right-click the Data Warehouse you extended for wish list events, point to New Cube, and then click Wizard.
In the Cube Wizard screen, click Next.
In the Select a fact table from a data source screen, in the Data sources and tables section, select Wishlist01, and then click Next.
In the Select the numeric columns that define your measures screen, in the Fact table numeric columns section, select Quantity, click the right arrow button, select Request Index, click the right arrow button, select Uri Key, click the right arrow button, select User Key, click the right arrow button, and then click Next.
In the Select the dimensions for your cube screen, click New Dimension.
In the Dimension Wizard screen, click Next.
In the Choose how you want to create the dimension dialog box, select Star Schema: A single dimension table, and then click Next.
In the Select the dimension table screen, select Wishlist01, and then click Next.
In the Select the dimension type screen, select Standard dimension, and then click Next.
In the Select the levels for your dimension screen, select ProductNameCat, click the right arrow button, and then click Next.
In the Specify the member key columns screen, click Next.
In the Select advanced options screen, click Next.
In the Finish the Dimension Wizard screen, in the Dimension name box, type ProductNameCat, and then click Finish.
In the Cube Wizard, in the Select the dimensions from your cube screen, click New Dimension again to create a second dimension.
Repeat steps 8 through 10.
In the Select the levels for your dimension screen, select Event,****click the right arrow button, and then click Next.
Repeat steps 12 and 13.
In the Finish the Dimension Wizard screen, in the Dimension name box, type Event, and then click Finish.
In the Select the dimensions for your cube screen, click Next.
In the Finish the Cube Wizard screen, in the Cube Name box, type Wishlist Activity, and then click Finish.
The Cube Editor screen appears, displaying the schema of the Wishlist Activity cube.
In the Cube Editor screen, on the File menu, click Exit.
In the Tree tab of Commerce Server Manager, expand Cubes, right-click Wishlist Activity, and then click Process.
In the Process a Cube dialog box, accept the defaults and click OK.
In the Process dialog box, click Close.
In Commerce Server Manager, expand Microsoft SQL Servers, expand SQL Server Group, expand the node for the local server, expand Databases, expand the node for the Data Warehouse that is being extended, and then click Tables.
In the details pane on the right side of the screen, right-click CubeProcInfo, point to Open Table, and then click Return all rows.
The contents of the CubeProcInfo table are displayed.
In the bottom row of the CubeProcInfo table, type the following information in the Entry column of the following table for each associated column:
Column name Entry CubeName Wishlist Activity IncEnabled 1 IsVirtual 1 Optimization <NULL> ProcessingEnabled 1 AutoPartition 1 FactTable dbo.Wishlist01 ProcessingKeySource dbo.ProductNameCat ProcessingKey ProductNameCat PartitionKeySource dbo.Wishlist01 PartitioningKey ProductNameCat PartitionSize <NULL> ProcessingPass 0 To exit the CubeProcInfo table, click the close button in the upper-right corner.
Before creating the report, you must run the Configuration synchronization DTS task, the Web server log import DTS task, and the Report preparation DTS task. For more information about running these tasks, see Running the Configuration Synchronization DTS Task, Running the Web Server Log Import DTS Task, and Running the Report Preparation DTS Task, respectively.
Open the Business Desk for the site.
In Business Desk, click Analysis, and then click Reports.
Click on the report toolbar to create your new report.
In the Create a new report - Web Page Dialog screen, do the following:
Use this To do this Report Type Select OLAP. Cube Name Select Wishlist Activity from the drop-down list. MDX Query Leave blank. Note
- If the PivotTable Field List does not appear automatically when you open the table, click on the PivotTable toolbar to view the PivotTable Field List.
Drag ProductNameCat from the PivotTable Field List and drop it into the Drop Row Fields Here box on the PivotTable.
Drag Event from the PivotTable Field List and drop it into the Drop Column Fields Here box on the PivotTable.
Drag Quantity from the PivotTable Field List and drop it into the Drop Totals or Detail Fields Here box on the PivotTable.
The total number of events for each product appears in the Grand Total column in the PivotTable.
Click on the toolbar to view the chart.
The chart for the data appears below the pivot table.
On the New Report page, click on the toolbar.
In the Save a report—Web Page Dialog screen, do the following:
Use this To do this Report Name Type the name of the new report. Report Category Type the report category. Report Description Type a description for the new report. Report Long Description Optional. Type a longer description for the report. This description will be visible in the browser above the PivotTable controls when you click above the PivotTable controls. Click OK.
Important
- When you save a new report, you are saving the report definition, not the data. The next time you run the report, it will have the same rows, columns, and filters, and current data will be queried from Microsoft SQL Server 2000 Analysis Services (OLAP) as specified in the report definition.
On the File menu, click Close.
Note
- For more information about working with PivotTables, click on the PivotTable toolbar.
See Also
Creating a New Dynamic Report Definition
Copyright © 2005 Microsoft Corporation.
All rights reserved.