Blog_Sitecore_Segment.jpg

An introductory series to Marketing Category Subscription in Sitecore

16.10.2019
Reading time: 4 min

An article series by Dirk Schäfauer.

Hey Sitecore crowd! Today I want to talk about leveraging the potential of the EXM preference center for the reverse cause: signing up for marketing categories (i. e. newsletters).

So, the topic might be called EXM Newsletter Subscription or something like that. But it’s much rather a Forms Extension where you sign up exclusively for marketing categories.

These marketing categories are based on the rules engine of Sitecore, so I do not want to classify them as EXM specific, they can also be used for marketing automation or personalization.

But let’s not get ahead of ourselves: In Sitecore 9.1, they introduced the Marketing Preference Center, a really cool way to manage marketing category subscriptions. However, the preference center is even more useful because it can be configured per manager root, is thus multi-site suitable and can look different for each site. Also custom Javascript-logic can be implemented there!

The only question that arises here is: If Sitecore does something great to unsubscribe from newsletters (or categories), why is there no great equivalent for signing up for these categories? The Preference Center is currently only available if you have already received a newsletter (for example Email Campaign Sample Newsletter). But what if I want to sign up for a marketing category?

Steve McGill about the Preference Center in “EXM and the complexity of Subscription Management“:

Email Preference Center
The release of Sitecore 9.1 introduces the much needed extra layer of preferences when determining who to send an email to. These preferences are designed to be visible to the customer, and Sitecore supplies a very simple UI out of the box, which is easy to skin to your own brand. (By the way, it makes use of a REST API, so you can easily move the example code to your own JSS / MVC component if you wish.)

Or Pete Navarra who puts it to the point in “Introduction to Email Experience Manager“:

Subscription management in EXM is provided as more of a full featured API with the expectation that it would be implemented to the client’s desires. So many business requirements can differ between implementations that building something out of the box would be insufficient or always need some modification. Instead, the route Sitecore has taken is to provide all of the endpoints and hooks needed, and allow the client to implement subscription management in the way they see fit.

The usecase or: how did I get into this

We had a difficult request from a client: They wanted to send newsletters from their own CRM via EXM. In principle that should be no problem. But to add contacts to contact lists was always faulty. Mostly, the lists were not fully indexed which resulted in incomplete shipping of the newsletter.

So, what if you want to have exactly what the Preference Center can do? Unfortunately, there is nothing for that out of the box.

There is a cool SubscriptionManager who calls a SubscribeEvent pipeline, the pipeline looks by default like this:

<SubscribeEvent patch:source="Sitecore.EmailExperience.ContentManagementPrimary.config"/>

Uhm, cool it’s empty! The “UnsubscribeFromList”-Pipeline is already filled with more life:

<UnsubscribeFromList patch:source="Sitecore.EmailExperience.ContentManagementPrimary.config">
<processor type="Sitecore.EmailCampaign.Cm.Pipelines.UnsubscribeFromList.GetList, Sitecore.EmailCampaign.Cm" resolve="true"/>
<processor type="Sitecore.EmailCampaign.Cm.Pipelines.UnsubscribeFromList.CheckDefaultExcludeCollection, Sitecore.EmailCampaign.Cm" resolve="true"/>
<processor type="Sitecore.EmailCampaign.Cm.Pipelines.UnsubscribeFromList.CheckSegmentedList, Sitecore.EmailCampaign.Cm" resolve="true"/>
<processor type="Sitecore.EmailCampaign.Cm.Pipelines.UnsubscribeFromList.CheckSubscription, Sitecore.EmailCampaign.Cm" resolve="true"/>
<processor type="Sitecore.EmailCampaign.Cm.Pipelines.UnsubscribeFromList.UnsubscribeContact, Sitecore.EmailCampaign.Cm" resolve="true"/>
<processor type="Sitecore.EmailCampaign.Cm.Pipelines.UnsubscribeFromList.SendNotification, Sitecore.EmailCampaign.Cm" resolve="true"/>
</UnsubscribeFromList>

Is that what I want to achieve? NO!
I do not want to subscribe or unsubscribe to lists anymore!
We want to do it the cool way!

In the following series of blog posts I will show you how to use the marketing categories especially for EXM. The idea behind it is pretty simple: Do it like the Preference Center which was introduced in Sitecore 9.1 and I use Sitecore Forms to handle all of that, the form itself has many surprises, it replaces the preference center which is no longer achievable if you delete the newsletter you already received.

The first idea was to subscribe the contacts by SubscriptionManager by it’s public method:

    public virtual bool Subscribe(
      ContactIdentifier contactIdentifier,
      Guid messageId,
      bool subscriptionConfirmation)

But I do not want to subscribe a contact to a message. The private method which Sitecore used inside is more reliable for me:

    private bool Subscribe(
      Contact contact,
      Guid recipientListId,
      ManagerRoot managerRoot,
      bool subscriptionConfirmation)

This is exactly what I needed! But it’s private. And here is where the real journey begins. ????

Read more in the following blog posts:
Part 1 – The Concept
Part 2 – Custom Field to get the Marketing Preferences and the contact list
Part 3 – Custom Marketing Preference Submit Action
Part 4 – Custom Field to identify Contacts
Part 5 – The “Magical” Subscription Form
Part 6 – Segmented Lists

OMG!
Sounds like a huge task! But accompany me on this journey and you will not regret it!

You can find the source code here: https://github.com/monkey-dsc/Feature.SitecoreForms.MarketingCategoriesSubscription/

Read the next part: Part 1 – The Concept

Happy reading
Dirk

The author

Dirk Schäfauer
Dirk Schäfauer
Dirk Schäfauer

The author

Contact