---
title: Collect data for reports
slug: commerce-connect-15/docs/collect-data-for-reports
createdAt: 2026-07-30T20:34:44.000Z
---

Optimizely Commerce Connect collects raw data for purchase orders and subscriptions and exports it under **Reports** in the UI for use in other applications.

The data-collection feature includes the following capabilities:

- Specify time periods for the data — for example, all orders created in the past 90 days — in `appsettings.json`.
- Collect data when an order is placed or when an existing order is modified by adding, updating, or removing line items.
- Run scheduled jobs that collect the raw data and export it as a compressed `.zip` file containing a CSV file.
- Show download links for exported `.zip` files in the **Reports** menu.
- Control access to the **Reports** menu through role-based permissions.

## Set the time range for reports

Set the report time range in `appsettings.json` or inside the `ConfigureServices` method of `Startup.cs`. The default value is 90 days. The following examples set a single value or multiple values:

```json
// appsettings.json
{
  "Commerce": {
    "ReportingTimeRangeOptions": {
      "TimeRangesInDays": [30, 60, 90, 180]
    }
  }
}
```

```csharp
// Startup.cs
public void ConfigureServices(IServiceCollection services)
{
    services.Configure<ReportingTimeRangeOptions>(o =>
    {
        o.TimeRangesInDays = new HashSet<int>() { 30, 60, 90, 180 };
    });
}
```

Each value is the number of days prior to the date the [scheduled job](docId\:qY-hx7Av08-i-_6e-XgwA) **Collect Report Data** runs. Both start and end dates are inclusive. The job creates one CSV file per value.

In the preceding example, the **Collect Report Data** scheduled job generates four CSV files: one for orders created in the last 30 days, one for the last 60 days, one for the last 90 days, and one for the last 180 days. Each CSV file is then compressed into a `.zip` file.

## Collect report data

### Use a scheduled job

To collect order data, run the **Collect Order Data for Reports** scheduled job from the **CMS Admin view**. The job collects order data in the background, and you can run it manually or at predetermined intervals like any other scheduled job.

![Screenshot of the Optimizely CMS scheduled-jobs page where the Collect Order Data for Reports job is selected.](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/zI-qUNyNdv0b2jrKxT6XO-20260723-164628.png)

The **Collect Subscription Data for Reports** scheduled job collects data for subscriptions. See [Collect subscription data](docId\:g8nrXMhp_PjX5DhsXhpDw) for details.

### Use order events

Commerce Connect can also collect order data when an order is placed or when an existing order is modified by adding, updating, or removing line items. This option is disabled by default. To enable it, set `ReportingOptions.EnableEventDrivenOrderReporting` to `true` in `appsettings.json` or inside the `ConfigureServices` method of `Startup.cs`:

```json
// appsettings.json
{
  "Commerce": {
    "ReportingOptions": {
      "EnableEventDrivenOrderReporting": true
    }
  }
}
```

```csharp
// Startup.cs
public void ConfigureServices(IServiceCollection services)
{
    services.Configure<ReportingOptions>(o =>
    {
        o.EnableEventDrivenOrderReporting = true;
    });
}
```

## Permissions for reports

Only users with the following roles can access the **Reports** menu in the Commerce Connect UI:

- `CommerceAdmins`
- `ReportManagers`

## Access collected data

After the report data is collected, a link to the exported `.zip` files appears under **Reports**. Click the link to download the data.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/WPVVp_RiaTN4zgWPBo5II_d3358aad308a3f4ca6716a7cfebe64681ffdfdefb4735267906addda31bd35b2-image.png)

## Data format

Report data is presented in comma-separated value (CSV) format. The following screenshot shows an example export:

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/sl-UCJKjvu4UweuX4oqWX-20260723-094602.png)

## Order data report contents

Each row in the order data report represents a line item from an order created during the specified time range, with the following columns:

- `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 order data](docId\:c7Y2GZof5z1doNGuwt56Y).

### Add properties to order data

If the default columns do not meet your requirements, add properties by overriding the `GetAdditionalData()` method on `ReportingAdditionalDataHandler`.

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

`DefaultReportingService.ExportOrderDataAsCsv()` calls `GetAdditionalData()` to populate `AdditionalValues`, then writes that column to the CSV file alongside the default columns.

## Related resources

- [Implementing a custom reporting service for commerce](https://www.brianweet.com/2020/04/29/implementing-a-custom-reporting-service-for-commerce.html) — community blog post by Brian Weet.
