Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Collect subscription data

Describes how to collect and access data for subscription reports in Optimizely Commerce Connect.

The data-collection feature exports raw subscription data over a configurable time range, run on a schedule. The collected data is available under Reports in the Commerce Connect UI.

See Collect data for reports for the order-data equivalent of the workflow described in this article.

A subscription supports recurring orders and lets payments span multiple cycles, giving you flexibility in how you sell products. Use the subscription-export feature to collect subscription data and export it for use in other applications.

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:

// appsettings.json
{
  "Commerce": {
    "ReportingTimeRangeOptions": {
      "SubscriptionTimeRangesInDays": [30, 60, 90, 180]
    }
  }
}
// Startup.cs
public void ConfigureServices(IServiceCollection services)
{
    services.Configure<ReportingTimeRangeOptions>(o =>
    {
        o.SubscriptionTimeRangesInDays = new HashSet<int>() { 30, 60, 90, 180 };
    });
}

Each value is the number of days prior to the date the Collect Reporting Subscription scheduled job runs. Both start and end dates are inclusive. The job creates one CSV file per value.

In the preceding example, the Collect Reporting Subscription scheduled job generates four CSV files: one for subscriptions 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.

Run the Collect Reporting Subscription scheduled job

Run the Collect Reporting Subscription scheduled job to collect subscription data in the background. Like any other scheduled job, you can run it manually or at predetermined intervals.

Screenshot of the Optimizely CMS scheduled-jobs page where the Collect Reporting Subscription job is selected.

Subscription report contents

Each row in the subscription report represents a line item from a subscription 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
  • SubscriptionId
  • Subscription Status
  • CustomerID
  • CustomerName
  • MarketId
  • Cycle Mode
  • Cycle Length
  • Max Cycles Count
  • Completed Cycles Count
  • Is Active
  • Start Date
  • End Date
  • Last Transaction Date
  • Total Revenue – Revenue of all orders completed during the subscription

Access the data

After the report data is collected, a link to the exported .zip files appears under Reports. Click the link to download the data, which is presented in comma-separated value (CSV) format.

Screenshot of the Reports menu in Commerce Connect listing the downloadable subscription .zip archive.

Related resources