I need to programmatically add contact to a contact list. How to do this in Sitecore 9.0.1? I find a documentation. Here it says this below line will add contact to a list.

    Contact contact = client.Get<Contact>(
        new ContactReference(contactId),
        new ContactExpandOptions(new string[1] { "ListSubscriptions" })

    contact.SetListSubscriptionsFacet(client, listId);


But I don't see this contact on my list in List Manager. Do I need to do more thing to see this contact?


2 Answers 2


Besides implementing the chorpo's code, please try enabling the indexing of anonymous contact data. To do that, please go to the following file locations of your xconnect site:



Then change the following tag in to true.


After that rebuild the xDb:

Go to the .xconnect\Website\App_data\jobs\continuous\IndexWorker and open the console window in administrator mode and run the command XConnectSearchIndexer -rr

You should see the contacts now.


With your code you are always changing facet value on contact so contact will be part of only one contact list (last one assigned) at the end.

You are also effectively replacing all other list subscriptions to that particular contact. This is bad practice.

You need to use this code snippet to achieve it:

ListSubscriptions subscriptions = new ListSubscriptions();
var listId = Guid.NewGuid(); /* Replace with real list ID */
var isActive = true;
var added = DateTime.UtcNow;

ContactListSubscription subscription = new ContactListSubscription(added, isActive, listId);

client.SetListSubscriptions(contact, subscriptions);

Taken from Sitecore xConnect docu page


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.