Area: Episerver Commerce

Collecting data for reports (Beta)

Recommendations [hide]

This story is a first step towards a new way of supplying order reports in Episerver Commerce.

Note: This is a Beta feature, which means that it is still in development. Read about how to enable Beta features here.

The feature provides raw data for created orders and includes

  • the ability to specify time periods for which you want the data (for example, all orders created in the past 90 days) in the web.config.
  • the ability to collect data when an order is placed or an existing order is modified.
  • a new scheduled job that collects the order raw data then exports it to a compressed zip file, which contains a csv file of order data.
  • a new Reports menu, which displays links for downloading exported zip files.
  • permissions that control access to the Reports menu.

The collected data is also used by the Sales by Day report.

Selection of time periods

You determine the time range for the reports in the web.config file, under <appSettings>.

<add key="episerver:commerce.ReportingTimeRanges" value="30;60;90;120"/>

Values are numbers of days prior to the date that you run the "Collect Report Data" scheduled job.

Begin and end dates are included in the order dates. For each value, the job creates one corresponding csv file.

The above example means that the Collect Report Data scheduled job generates 4 csv files: one for all orders created within the last 30 days, another for orders created within the last 60 days, and so on.

Each csv file is compressed in a .zip file.

In the example below, the report compiles one report containing order data for the past year (365 days).

<add key="episerver:commerce.ReportingTimeRanges" value="365" />

 Note: If the web.config has no settings for episerver:commerce.ReportingTimeRanges, the default value is 90.

Collect the report data

Using a scheduled job

A new scheduled job, Collect Report Data, collects order data in the background. Like other scheduled jobs, you can run this manually or at predetermined time intervals.


Using order events

Order data can also be collected whenever an order is placed or an existing order is modified by adding, updating, or removing line items. Use the following web.config setting, which occurs under <appSettings>, to determine whether to collect order data when these order events occur.

<add key="episerver:commerce.EnableEventDrivenOrderReporting" value="true"/>

 Note: If no value is set for episerver:commerce.EnableEventDrivenOrderReporting, order data is collected. In other words, the default value is True.

Order data

Which data to collect for reports is still under development. The Episerver Commerce team is requesting beta users to provide feedback on which data should be collected.

This version provides the following information for each order created during the specified time range in LineItem level.

  • LineItemID
  • LineItemCode
  • DisplayName
  • PlacedPrice
  • Quantity
  • ExtendedPrice
  • EntryDiscountAmount: The line item's discount amount
  • SalesTax
  • Currency
  • OrderGroupId
  • OrderNumber
  • CustomerID
  • CustomerName
  • MarketId
  • OrderCreated: The order creation date
  • AdditionalValues - see Add properties to your Order data.

Add properties to your Order data

If the default values do not satisfy your needs, you can add properties by overriding the GetAdditionalData() method of ReportingAdditionalDataHandler.

public override IEnumerable<string> GetAdditionalData(ILineItem lineItem, IPurchaseOrder order)
       return new string[] { order.MarketId.Value, order.OrderStatus.ToString(), lineItem.InventoryTrackingStatus.ToString() };

Our extension point in DefaultReportingService.ExportOrderDataAsCsv() calls to GetAdditionalData() to assign value for AdditionalValues, then exports AdditionalValues like other default values to the csv file.


Only users with following roles can access the new Reports menu.

  • CommerceAdmins and EPiBetaUsers
  • ReportManagers and EPiBetaUsers

Accessing the collected data

A link to the exported .zip files appears on the new Commerce Reports menu. Click a link to download the data.


Data format

Collected report data is presented in a comma-separated value (CSV) format.
Open full-size image in new window 


Related topics

Do you find this information helpful? Please log in to provide feedback.

Last updated: Aug 20, 2018

Recommendations [hide]