Web 8, DXA and Working with Audience Manager CD API

Recently, I got a chance to work on a migration project on Web 8 and DXA which is using a lots of functionality on the website through audience manager like User Registration, Login, Personalization of content and documents etc.

While, the audience manager API sounds good on CM side, on the CD side the audience manager API is quite restricted in the capabilities.

I am just mentioning here how to use this (if ever there is a need) and few examples.

Before we jump on the examples; following are notes:

  • To starts with, you need to get the Audience Manager CD API – You can install the Sdl.AudienceManager.ContentDelivery.dll from the nuget
  • The Audience Manager CD API, can only work with a single contact at a time – so you can not fetch a list of all users in a address book, filter contacts based on a particular attributes or query contacts – At max you can get details of a contact based on unique identification.
  • There is no method to identify whether a Contact exists in the Audience manager

Examples:

  1. Getting a contact from Audience Manager based on the email id:
    using Sdl.AudienceManager.ContentDelivery;
    ....
    ....
    Profile.Contact contact = Profile.Contact.FromEmailQueryString("<email address of contact>");
  2. Getting a contact from Audience Manager based on the contact identification key:
    Profile.Contact contact = Profile.Contact.FromIdentificationKeys("<identification keys>");
  3. Getting extended information of a contact like First Name, Last Name, Contact Number etc.
    Profile.Contact contact = Profile.Contact.FromEmailQueryString("<email address of contact>");
    
    string strValue = contact.ExtendedDetails["fieldName"].StringValue;
    //examples:
    string firstName = contact.ExtendedDetails["FirstName"].StringValue;
    DateTime dob = contact.ExtendedDetails["dob"].DateValue;
    int age = contact.ExtendedDetails["age"].IntegerValue;
  4. Creating a new contact in Audience Manager:
    Profile.Contact contact = new Profile.Contact();
    contact.Enabled = true;
    contact.CreationDate = DateTime.Now;
    contact.SubscribeStatus = Profile.SubscribeStatus.Subscribed;
    contact.ExtendedDetails["fieldName"].StringValue = "fieldvalue";
    //examples
    contact.ExtendedDetails["EMAIL_ADDRESS"].StringValue = "email-address";
    contact.ExtendedDetails["FIRSTNAME"].StringValue = "FirstName";
    contact.ExtendedDetails["LASTNAME"].StringValue = "LastName";
    ....
    ....
    contact.Save()
  5. Creating a new contact in a specific Address Book in Audience Manager
    Profile.Contact contact = new Profile.Contact();
    contact.Enabled = true;
    contact.CreationDate = DateTime.Now;
    contact.SubscribeStatus = Profile.SubscribeStatus.Subscribed;
    contact.ExtendedDetails["fieldName"].StringValue = "fieldvalue";
    
    contact.AddressBookId = 5; // the ID of the desired address book
    
    contact.Save()
Advertisements

11+ years of experience in Software Development Life Cycle using AGILE, Iterative and RUP approaches. Hand-on experience in following: - CMS packages: SDL Tridion, Umbraco, Kentico, SiteFinity and Alfresco - Search Engines: SOLR, Endecca, FAST - .NET Technologies: .NET & .NET CE Framework, ASP.NET, ASP.NET MVC, WCF, WinForms - Mobile Development: Android Native App, Windows Mobile App - Database: MS-SQL Server, MySQL - Program Management: JIRA, MS-Project - Design Tools: MS-Visio, StarUML Have decent knowledge about Core Java, Spring MVC, Ektron and Google Mini Instrumental in Application Architecture, Designing (HLD & LLD), Coding and deployment .NET applications (Web, Desktop, Mobile). Experience in following domain: - Digital Media & eCommerce - Travel & Hospitality - Aviation Industry - Education - Insurance - Automation - Automobile - Railways Freelance trainer and consultant in .NET, CMS, SDL Tridion, Alfresco and soft skills like business communication, e-mail etiquette etc. Education: Bachelor Degree in Computer Engineering and Post Graduate Diploma in Business Administration with specialization in Marketing

Tagged with: , ,
Posted in SDL Tridion

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: