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.
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:
LineItemIDLineItemCodeDisplayNamePlacedPriceQuantityExtendedPriceEntryDiscountAmount– The line item's discount amountSalesTaxCurrencySubscriptionIdSubscription StatusCustomerIDCustomerNameMarketIdCycle ModeCycle LengthMax Cycles CountCompleted Cycles CountIs ActiveStart DateEnd DateLast Transaction DateTotal 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.
Related resources
- Implementing a custom reporting service for commerce — community blog post by Brian Weet.
Updated 20 days ago
