マーケティングオートメーションレポートAPI

Version:
日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

Marketing Automation Reporting APIを使用すると、呼び出し元はプランとアクティビティの統計とメトリックを取得できます。

自動化レポート・クライアントへのアクセス

次の例は、SitecoreコンテキストでIAutomationReportingClientにアクセスする方法を示しています。

using Sitecore.DependencyInjection;
using Sitecore.Xdb.MarketingAutomation.ReportingClient;
using Microsoft.Extensions.DependencyInjection;

namespace Documentation
{
    public class AutomationAPI
    {
        public void Example()
        {
            var reportingCLient = ServiceLocator.ServiceProvider.GetService<IAutomationReportingClient>();
        }
    }
}

オペレーションズ

メモ

各メソッドには、同期バージョンと非同期バージョンがあります。

プランの統計情報を取得する

GetPlanStatisticsAsync() メソッドは、プランIDのリストを受け取り、PlanStatisticsオブジェクトのリストを返します。次の例は、使用可能な統計の詳細を示しています。

using Sitecore.DependencyInjection;
using Sitecore.Xdb.MarketingAutomation.ReportingClient;
using Microsoft.Extensions.DependencyInjection;
using System;
using Sitecore.Xdb.MarketingAutomation.Core.Reporting;
using Sitecore.Xdb.MarketingAutomation.Core.Collections;

namespace Documentation
{
    public class GetPlanStats
    {
        public async void Example()
        {
            var reportingClient = ServiceLocator.ServiceProvider.GetService<IAutomationReportingClient>();

            var result = await reportingClient.GetPlanStatisticsAsync(new[]
            {
                Guid.Parse("{19F1B472-11E4-4927-84EC-71E10136CE4E}"), // Plan ID #1
                Guid.Parse("{6CCC76C7-85DE-4214-B51B-D045065129A7}") // Plan ID #2
            });

            foreach (PlanStatistics stat in result)
            {
                Guid planID = stat.PlanDefinitionId; // The plan ID
                long allEnrollmentsCount = stat.AllEnrollmentCount; // All enrollments in the history of this plan
                long currentEnrollmentsCount = stat.CurrentEnrollmentCount; // Current enrollments
            }
        }
    }
}
手記

指定されたIDでプランが見つからない場合、そのIDは何も返されません。たとえば、リクエストに5つのIDが含まれていて、2つのIDが見つからない場合、システムは3つのID PlanStatistics インスタンスのみを返します。

プラン レポートを取得する

GetPlanReportAsync() メソッドは、1つのプランID、開始日、および終了日を受け取り、PlanReportを返します。開始日と終了日は、ActivityCurrentContactCountPlanCurrentContactCountの値に影響します。次の例は、使用可能な統計の詳細を示しています。

using Sitecore.DependencyInjection;
using Sitecore.Xdb.MarketingAutomation.ReportingClient;
using Microsoft.Extensions.DependencyInjection;
using System;
using Sitecore.Xdb.MarketingAutomation.Core.Reporting;
using Sitecore.Xdb.MarketingAutomation.Core.Collections;

namespace Documentation
{
    public class GetPlanReport
    {
        public async void Example()
        {
            var reportingClient = ServiceLocator.ServiceProvider.GetService<IAutomationReportingClient>();

                            var planId = Guid.Parse("{C5F5C4AA-3D00-41ED-AEA2-740129E340E3}");
                            var reportStart = DateTime.UtcNow.AddDays(-1);
                            var reportEnd = DateTime.UtcNow;
            var result = await reportingClient.GetPlanReportAsync(planId, reportStart, reportEnd);

            var allContactsByActivity = result.ActivityAllContactCount; // The number of contacts that have ever been enrolled by each activity. The dictionary key is the ID of the activity and the value if the enrollment count.
            var allCurrentContactsByActivity = result.ActivityCurrentContactCount; // The number of contacts enrolled by each activity within the start and end dates. The dictionary key is the ID of the activity and the value if the enrollment count.
            var allContacts = result.PlanAllContactCount; // The number of contacts that have ever been enrolled in any activity of the plan. This is basically a sum of all of the counts from the ActivityAllContactCount dictionary.
            var currentContactCount = result.PlanCurrentContactCount; // The number of contacts enrolled in any activity of the plan within the start and end dates. This is basically a sum of all of the counts from the ActivityCurrentContactCount dictionary.
        }
    }
}
この記事を改善するための提案がある場合は、 お知らせください!