Create a contact processor
This topic demonstrates how to create and register your own contact processor.
Inherit ContactProcessingProcessor
Inherit ContactProcessingProcessor
All contact processors inherit from Sitecore.Analytics.Aggregation.Pipeline.ContactProcessingProcessor:
Specify contact facets to retrieve
Specify contact facets to retrieve
The processing pipeline uses the xConnect Client API to retrieve contacts. You must specify which contact facets to retrieve by decorating your processor with UsesContactFacets.
Example of usage:
It is recommended that you do not hard-code facet keys - Sitecore’s built-in facet names are located on the facet object itself - such as PersonalInformation.DefaultFacetKey.
If you do not explicitly request a particular facet, it will not be available during processing. To understand why, read more about the role of expand options when getting contacts.
Using ContactProcessingArgs
Using ContactProcessingArgs
Accessing the contact
The contact is available directly on the args:
If you requested any contact facets, they can be accessed via the .GetFacet<T> extension method:
Alternatively, use the extension methods found in Sitecore.XConnect.Collection.Model:
Access processing reason
The args.ProcessingReason property returns an enum of type Sitecore.Analytics.Processing.ProcessingReason, which tells you why the contact is being processed in the first place.
-
Created: The contact is new -
Updated: The contact was updated -
Obsoleted: The contact identifier has been obsoleted -
Unknown: Reason for processing is unknown
Accessing other APIs
Every processor has access to the following APIs via args.Sources:
-
xConnect Client API
-
Reference Data Service
-
Defintion managers
-
Taxonomy managers
In the context of a contact processor, all service end points - xConnect, definitions, taxonomy, and the reference data service - should be treated as read-only.
Accessing xConnect
A read-only instance of the xConnect Client API is accessed via args.Sources.Collection. You can search or get contact data:
Remember that the contact is available via args.Contact.
Accessing definition managers
Accessing taxonomy managers
Accessing the reference data service
The contact processing pipeline uses a read only version of the reference data service API - it does not use the client API.
Configuring a contact processor
Configuring a contact processor
Add your processor to the contact processing pipeline as shown: