1. List Manager

List Manager API

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

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

Sitecoreはマーケティングの定義として連絡先リストを保存しています。コンテンツマネージャー(CM)インスタンスでは、List Manager APIを使ってプログラム的に連絡先リストにアクセスできます。

!注Content Delivery(CD)インスタンスではList Manager APIを使うことはできません。なぜなら、この場合はList Managerアプリケーションが無効化されているからです。

セグメントの追加、更新、削除

この例は、List Manager APIを使ってセグメントを追加する方法を示しています。

!注セグメントルールの作成および変更はList Managerインターフェースを通じてのみ行えます。

var segmentRepository = ServiceLocator.ServiceProvider.GetService< SegmentRepository>();

var newSegment = new SegmentModel       {          Id = Guid.NewGuid().ToString("B"),          Name = "New Segment",          Description = "New Description",          UseAsAnalyticsFilter = true       };

segmentRepository.Add(newSegment);

この例はセグメントの更新方法を示しています。

var segmentRepository = ServiceLocator.ServiceProvider.GetService< SegmentRepository>();

//Find existing segment by ID. ID must be vali var segmentToUpdate = segmentRepository.FindById("{00000000-0000-0000-0000-000000000000}"); segmentToUpdate.Description = "New Description"; segmentRepository.Update(segmentToUpdate);

この例はセグメントを削除する方法を示しています。

var segmentRepository = ServiceLocator.ServiceProvider.GetService<IFetchRepository>();

//Find existing segment by ID. ID must be valid.

var segmentToDelete =  segmentRepository.FindById("{00000000-0000-0000-0000-000000000000}"); segmentRepository.Delete(segmentToDelete);

セグメント化されたリストの追加、更新、削除

この例は、セグメント化されたリストを追加する方法を示しています。

var segmentedListRepository = ServiceLocator.ServiceProvider.GetService< SegmentedListRepository>();

var newSegmentedList = new SegmentedListModel()             {                 Id = Guid.NewGuid().ToString("B"),                 Name = "New Contact List",                 Description = "Description of the contact list",                 Owner = "Administrator"             };

作成したいリストにセグメントを追加するには、このコードスニペットを使ってください。

newSegmentedList .SegmentIds = new {“”};

新しい分割リストを保存するには、このコードスニペットを使ってください。

segmentedListRepository.Add(newSegmentedList);

この例は、分割されたリストを更新する方法を示しています。

var segmentedListRepository = ServiceLocator.ServiceProvider.GetService< SegmentedListRepository>();

//Find existing list by ID. ID must be valid.

var listToUpdate =  segmentedListRepository.FindById("{00000000-0000-0000-0000-000000000000}"); listToUpdate.Description = "New Description"; segmentedListRepository.Update(listToUpdate);

この例は、分割されたリストを削除する方法を示しています。

var segmentedListRepository = ServiceLocator.ServiceProvider.GetService<IFetchRepository>();

//Find existing list by ID. ID must be valid.

var listToDelete =  segmentedListRepository.FindById("{00000000-0000-0000-0000-000000000000}"); segmentedListRepository.Delete(listToDelete);

連絡先リストの追加、更新、削除

この例は連絡先リストの追加方法を示しています。

var contactListRepository = ServiceLocator.ServiceProvider.GetService<IFetchRepository< ContactListModel>>(); var newContactList = new ContactListModel()        {            Id = Guid.NewGuid().ToString("B"),            Name = "New Contact List",            Description = "Description of the contact list",            Owner = "Administrator"        };

作成したいリストに含まれているリストを追加するには、このコードスニペットを使ってください。

newContactList.Subscriptions.Add(new SubscriptionViewModel             {               Id = Guid.NewGuid(),                ListId = , Name= "Name of the included list"             });

新しい連絡先リストを保存するには、このコードスニペットを使ってください。

contactListRepository.Add(newContactList);

この例は連絡先リストの更新方法を示しています。

var contactListRepository = ServiceLocator.ServiceProvider.GetService<IFetchRepository< ContactListModel>>();

//Find existing list by ID. ID must be valid. var listToUpdate =  contactListRepository.FindById("{00000000-0000-0000-0000-000000000000}"); listToUpdate.Description = "New Description"; contactListRepository.Update(listToUpdate);

この例は連絡先リストの削除方法を示しています。

var contactListRepository = ServiceLocator.ServiceProvider.GetService<IFetchRepository< ContactListModel>>();

//Find existing list by ID. ID must be valid.

var listToDelete =  contactListRepository.FindById("{00000000-0000-0000-0000-000000000000}"); contactListRepository.Delete(listToDelete);

コンタクトの追加・削除

この例は、連絡先リストに1つの連絡先を追加する方法を示しています:

var subscriptionService = ServiceLocator.ServiceProvider.GetService(); subscriptionService.Subscribe(contactListId, contactId);

この例は、連絡先リストに複数の連絡先を追加する方法を示しています:

var contacts = new List(); // List of contacts var subscriptionService = ServiceLocator.ServiceProvider.GetService(); subscriptionService.Subscribe(contactListId, contacts);

接触関連を解除し、対応するメソッドをISubscriptionServiceから呼び出すには:

var subscriptionService = ServiceLocator.ServiceProvider.GetService(); subscriptionService.Unsubscribe(contactListId, contactId); subscriptionService.Unsubscribe(contactListId, contacts);

リストに関連付けられた連絡先の取得

この例は、連絡先リストから連絡先を取得する方法を示しています:

int batchSize = 200; // Size of the batch string facets = { CollectionModel.FacetKeys.PersonalInformation, CollectionModel.FacetKeys.ListSubscriptions }; // Contact facets to retrieve var contactListProvider = ServiceLocator.ServiceProvider.GetService(); var contactProvider = ServiceLocator.ServiceProvider.GetService(); var contactList = contactListProvider.Get(contactListId, cultureInfo); var contactBatchEnumerator = contactProvider.GetContactBatchEnumerator( contactList, batchSize, facets); while (contactBatchEnumerator.MoveNext()) { var contacts = contactBatchEnumerator.Current; // write your logic here contacts.ToList(); }

この例では、バッチ列挙子を接触を反復する最も効率的かつ迅速な方法として使っています。詳細はxConnectのドキュメントをご覧ください。

この記事を改善するための提案がある場合は、 お知らせください!