Configure the Import Wizard to include custom contact facets

Abstract

Configure the import of custom contact data from a CSV file.

In the List Manager, when a marketer imports contacts from a CSV file, they can map fields from the imported file to the following default Sitecore fields:

  • Identifier

  • Email address

  • First name

  • Last name

1320968E73E94552BE0F729C97BB0135.png

If the marketer needs additional Sitecore fields to map the imported file fields to, you can extend the Import contacts wizard to include:

  • Predefined contact facets – in the Sitecore.Analytics.Model.config file, in the sitecore/model/entities/contact/facets section, you can see the available predefined contact facets that you can add to the Import contacts wizard:

    • Personal

    • Addresses

    • Emails

    • Phone Numbers

    • Picture

    • Communication Profile

    • Preferences

  • New custom contacts facets – you can create a custom contact facet and then update the model configuration to include it in the Import contacts wizard.

This topic includes how to:

To extend the Import contacts wizard to display a predefined facet as a Sitecore mapping field, you must first create a new import model field for the predefined facet in the Content Editor and then update the Sitecore.Analytics.config file.

To add a predefined facet as a mapping field:

  1. In the Core database, in the Content Editor, navigate to the ImportModel folder (/sitecore/client/Applications/List Manager/Dialogs/ImportWizardDialog/PageSettings/TabControl Parameters/Map/ImportModel).

  2. Create a new Import model field item based on the ImportModelField template. To do this, in the ImportModel folder, duplicate one of the existing items and modify it according to the following steps.

  3. In the new item, in the FieldName field, specify the name of the Sitecore mapping field to display in the Import contacts wizard.

  4. In the DataField field, specify the name of the property within the facet in the JSON format. Configure the DataField using one of the following examples:

    • Direct Mapping maps to the destination object directly, for example:

      Identifiers.Identifier

    • Facet Mapping gets a facet and then sets its properties, for example:

      {facet:"Personal",property:"FirstName"}

    • Preferred Entry Faced Mapper creates a Preferred element dictionary entry and sets its properties, for example:

      {facet:"Emails",preferred:true,entryProperty:"SmtpAddress"}

    7E7CC383EE1D40E685745A79B44D4CEC.png
  5. To add the corresponding processor to the Sitecore.Analytics.config file, in the Sitecore.Analytics.config file, in the <analytics.bulk.contact> section, add the corresponding processor to the updateFields pipeline, for example:

     <processor type="Sitecore.Analytics.Data.Bulk.Contact.Pipelines.UpdateFields.UpdateAddresses, Sitecore.Analytics" />
    <processor type="Sitecore.Analytics.Data.Bulk.Contact.Pipelines.UpdateFields.UpdateCommunicationProfile, Sitecore.Analytics" />
    <processor type="Sitecore.Analytics.Data.Bulk.Contact.Pipelines.UpdateFields.UpdatePhoneNumbers, Sitecore.Analytics" />
    <processor type="Sitecore.Analytics.Data.Bulk.Contact.Pipelines.UpdateFields.UpdatePicture, Sitecore.Analytics" />
    <processor type="Sitecore.Analytics.Data.Bulk.Contact.Pipelines.UpdateFields.UpdatePreferences, Sitecore.Analytics" />
    

Note

The processors Personal info and Email addresses are already handled by List Manager and do not need to be registered.

To extend the Import contacts wizard to display a custom contact facet, for example, CompanyName, you must first create a new custom contact facet, then register the custom contact facet in the Sitecore.Analytics.Model.config file, and then create a new import model field for it before finally updating the Sitecore.Analytics.config file.

To add a new custom contact facet as a new mapping field:

  1. When you create a new custom contact facet, create a new class library project, for example, CustomFacets, with the following classes:

    //ref to Sitecore.Analytics.Model.dll added
    namespace CustomFacets
    {
        using Sitecore.Analytics.Model.Framework;
        public interface ICompanyFacet : IFacet
        {
            string Company { get; set; }
        }
    }
    namespace CustomFacets
    {
        using System;
        using Sitecore.Analytics.Model.Framework;
        [Serializable]
        public class CompanyFacet : Facet, ICompanyFacet
        {
            private const string COMPANY = "Company";
            public CompanyFacet()
            {
                this.EnsureAttribute<string>(COMPANY);
            }
            public string Company
            {
                get
                {
                    return this.GetAttribute<string>(COMPANY);
                }
                set
                {
                    this.SetAttribute(COMPANY, value);
                }
            }
        }
    }
    
  2. In the Sitecore.Analytics.Model.config file, register the custom contact facet you created:

    • In the sitecore/model/elements section, register the following element:

    <element>
    <element interface="CustomFacets.ICompanyFacet, CustomFacets" implementation="CustomFacets.CompanyName, CustomFacets"/>
    </element>
    
    • In the sitecore/model/entities/contact/facets section, add the new custom facet that you created, for example:

    <facets>
    …
    <facet name="CompanyName" contract="CustomFacets.ICompanyFacet, CustomFacets" />
    </facets>
    
  3. In the Core database, in the ImportModel folder, (/sitecore/client/Applications/List Manager/Dialogs/ImportWizardDialog/PageSettings/TabControl Parameters/Map/ImportModel), create a new Import model field item for the new facet based on the ImportModelField template (/sitecore/client/Applications/List Manager/Templates/ImportModelField).

  4. In the new item, in the FieldName field, specify the name of the Sitecore mapping field in the Import contacts wizard.

  5. In the DataField field, specify the name of the property within the custom facet in the JSON format. For example:

    • Direct Mapping maps to the destination object directly, for example:

      Identifiers.Identifier

    • Facet Mapping gets a facet and then sets its properties, for example:

      {facet:"Personal",property:"FirstName"}

    • Preferred Entry Faced Mapper creates a Preferred element dictionary entry and sets its properties, for example:

      {facet:"Emails",preferred:true,entryProperty:"SmtpAddress"}

    2D9344E8404543A5B1098DD30C762CEC.png
  6. When you have registered the new facet, to add the corresponding processor to the Sitecore.Analytics.config file, in the Sitecore.Analytics.config file, in the <analytics.bulk.contact> section, add the processor to the updateFields pipeline, for example:

    <processor type="Sitecore.ListManagement.Analytics.Data.Bulk.Contact.Pipelines.UpdateFields.DeepCopyFacet`1[[CustomFacets.ICompanyFacet, CustomFacets]], Sitecore.ListManagement.Analytics">
        <param desc="facetName">CompanyName</param>
    </processor>