Rebuild sitecore_analytics_index contact data

There’s been an interesting question around how to rebuild the sitecore_analytics_index but specifically only for contact data.

As you’ve probably know that sitecore_analytics_index is not available to be indexed manually – go to the indexing manager in the control panel if you want to check. This is because the index is configured using an observer crawlers.

However there are ways to manually rebuild the sitecore_analytics_index. The example given in that seems to be specifically about rebuilding the interactions documents while what we want is to build the contacts.

I gained some hints from the provided example though, let’s have a look at the following code.

In particular this line

I then go to the handy showconfig.aspx page to find the following

Which shows the processingPools configured for the aggregation processes. From there I can spot the contact element definition which seems to be the one that I’m looking for and start building the code for it.


Depending on your needs, you might want to only reindex known contacts for example. You can take the above example and adjust it yourself.


Sitecore 8 – Extending Experience Profile – Part 4 – Displaying Specific Interactions Data

How to display specific interaction data

For this example, we would like to have a custom list in the Experience Profile where it listed the triggered page event when the site visitor downloaded a PDF file.

End result:



How to set this up

Source code link is available at the end of this post.

How to setup a new page event

First we need to create a page event through the content editor, we can do so by going to the /sitecore/system/Settings/Analytics/Page Events

In the below screenshot I’ve created a page event called “Download PDF File”



How to assign page event to a media item

There’s a tutorial on how to this on Sitecore documentation site

I’m using a page event rather than goal for this POC because this event “download a pdf” doesn’t necessarily lead to a conversion but more about the actions that the site visitors took that we want to be aware of.

In the screenshot below I’ve assigned the pdf files in the media library with my custom page event.


Now if there’s a site visitors that download the specified files on the website, Sitecore will trigger the page event and store the information in MongoDB which later on we will extract and display it in the Experience Profile.

How to setup the custom tab in Experience Profile

The content tree


We define three column to be displayed on the ListControl rendering.


The full list of the renderings


The SubPageCode rendering links to a javascript file downloadedpdffiles.js which will be executed when this item is loaded into the tab.

We can control the page size -the amount of records returned by the server-  in the GenericDataProvider properties.

How to register a new processors for the Experience Profile

Jonathan Robbin’s blog post explain it nicely on what this processors is doing.







Register our custom processors


notice that the sorting and paging is already built in the framework.

Register our custom result transformer



Wire things together

As with the previous post, when the DownloadedPdfFilesPanel item is loaded we will trigger an API call to request the data to be displayed in the list control

The javascript file that’s responsible to do this is the downloadedpdffiles.js

The difference here compared to the previous post when triggering the API call is that we specify the /intel/downloadedpdffiles in the url which Sitecore recognize to be a special route. This route will try to run donwnloadedpdffiles pipelines that we define earlier in the config file.

An example of the API response



Source code

Source code is available in Github

Sitecore 8 – Extending Experience Profile – Part 3 – Displaying Contact Facet Collection Property

How to display contact facet collection property

End result:


How to set this up

Source code link is available at the end of this post.

How to setup the custom contact facet

Similar to what we’ve done in the first post, the only difference here is that we are using collection property instead of simple properties.


The  updated TC.Sitecore.Analytics.Model.config file

note that we need to register our INewsletterElement as well in order for Sitecore to know which type to resolve during runtime.

An example of how the data is being stored in MongoDB



How to setup the web API controller

The updated InitializeRoutes.cs


The updated CustomContactController.cs


The main reason why we are returning as a ResultSet object here is that the list control rendering expects the returned data in a specific JSON structure.

While going through this I thought of the performance implications if we have a lot of data where we should ideally implement pagination when querying against MongoDB. For this POC, this works fine as for newsletters typically the users won’t have thousands of records to be displayed .

An example on how to implement pagination will be provided in the next post.


How to setup a custom tab in Experience Profile

The content tree


Under the NewsletterSubscriptionPanel item you can that there’s NewsletterSubscriptions which based on ListControl template, under that we have the NewsletterName which is using the ColumnField template.

When we use the list control rendering, we can specify what columns are there in the list control and bind the value with a specific property name returned from the API



The full list of the renderings used


note that there’s “more” button assigned to the layout, but this didn’t actually being used. That’s for future improvements when we implement pagination.


Wire things together

As with the previous post, when the NewsletterSubscriptionPanel item is loaded we will trigger an API call to request the data to be displayed in the list control

The javascript file that’s responsible to do this is the newslettersubscriptions.js


An example of the API response


note that it has to return the response in a specific JSON structure that the list control can consume.


Source code

Source code is available in Github

Sitecore 8 – Extending Experience Profile – Part 2 – Displaying Contact Facet Simple Properties

How to display contact facet simple properties

End result:


There’s a good reference on how to create a custom tab in Sitecore Experience Profile on Jonathan Robbins blog post,  I recommend you go and read it through.

How to set this up

Source code link is available at the end of this post.

How to setup the custom contact facet

There’s a good reference on Sitecore documentation site on how to do so.

In my custom facet I only have two properties, which is the HospitalName and the ProfessionName.





And the config patch file to register this custom facet



To fillout the data in the custom facet I’ve setup a page to do this



How to setup the web API controller

First we need to register our custom route to our custom controller



In our custom controller, we just return the custom facet that contains all the properties that we want to display in Experience Profile



Finally we add the InitializeRoutes class to the pipeline



How to setup a custom tab in Experience Profile

I will not go in detail on how I setup the content tree as the reference I’ve provided should give you an idea on how to set it up and I’ll be providing the source code at the end of this post.

This is the content tree in the core database that I’ve setup in order to display those 3 tabs


The first tab which is the Profession tab will be displaying the custom field from the custom contact facet that I’ve setup.

The rendering items


Wire things together

To display this information, after our Profession tab is loaded in the Experience Profile we would need to call our CustomContactController class to retrieve the data.

The code that’s responsible to do this is the profession.js that is set in the SubPageCode rendering control in the ProfessionPanel layout. This javascript file is executed when the ProfessionPanel item is loaded into the Profession tab




The script basically calls an API method in the server which then gives back the response in a JSON format which we then assign to the controls defined in the ProfessionPanel item layout.


This is the full url it’s trying to access

It’s passing the current contact id and a specific url ‘customfields’ which we route to our custom web API controller. It will then use the cintelUtil helper to bind the data to the text controls defined in our ProfessionPanel layout.


Source code

Source code is available in Github

Sitecore 8 – Extending Experience Profile – Part 1 – Overview

I will be creating a series of blog posts on a recent POC that I’ve done on how to extend Sitecore 8 Experience Profile

This was done using Sitecore 8.1 update 1 at the time of writing.

There will be several things that this blog posts tries to cover

  1. How to display contact facet simple properties
  2. How to display contact facet collection property to a list control
  3. How to display specific interaction data to a list control

End results

Displaying contact facet simple properties

The below screenshot is an example on how to retrieve simple properties from the contact facet and then display them in our custom tab



Displaying contact facet collection property to a list control

The below screenshot is an example on how to retrieve collection property from the contact facet and then bind it to a list control



Displaying specific interaction data to a list control

The below screenshot is an example on how to retrieve specific interaction data, which in this case a Page Event that’s triggered whenever a site visitor downloaded a pdf file.



Details on how to achieve this will be explained the next posts.


Sitecore 8 – how to update contact through FXM API

This post will talk through how to setup a custom actions to be executed to update Sitecore contact through FXM API. If you don’t know about FXM you can read a brief overview about it in the Sitecore site and the doc site

If you’ve played around with FXM and it’s javascript API then you would know that you can trigger client side call to send information back to Sitecore regarding the current visitor browsing behaviour. But what does one do if we want to update the Contact information instead? say the current visitor email address if they fill out a newsletter subscription form? or their unique user id if they have logged in through the external application?

Looking at the available javascript FXM API there’s these three methods available:

  1. SCBeacon.trackEvent
  2. SCBeacon.trackGoal
  3. SCBeacon.trackOutcome

and there’s no such things as SCBeacon.updateContact which we sought after. After some investigation there’s a couple of ways to do this.

1. A custom web service call to the Sitecore server

Setup a custom web service in Sitecore server and pass in the current visitor contact id for custom processing. Doable but I’m looking for something that can be done through the same javascript API if possible as it would mean greater coverage – can be reused by other external site. By doing it through FXM javascript API we don’t have to setup web service call in each external sites.

2. Modify the beacon script to include our custom function 

Modify the beacon script and include the custom SCBeacon.updateContact function. Figured that this won’t be ideal as we would muck around with the bundled javascript and won’t be compatible in Sitecore future upgrades.

3. Hook into one of the available methods to do some custom processing

This seems like the best place to start. Out of the available methods I choose to override the trackEvent tracking implementation because the action that I want to captured falls to “system” type action, doesn’t relate to conversion (Goal) or has monetary value (Outcome). Plus if I use page events then by default the events triggered will not show in the Experience Profile which might confused the marketers.

OK, let’s do this.

This is done with the latest Sitecore version at the time of writing which is 8.1 update 3.

First let’s open the Sitecore.FXM.config in /website/app_config/include/fxm folder

I opened up Sitecore.FXM.Pipelines.Tracking.TriggerPageEvent.RunRegisterPageEventProcessor using dotPeak to find out that it will run the tracking.registerpageevent pipeline

When I take a look at Sitecore.FXM.Pipelines.Tracking.RegisterPageEvent.RegisterPageEventProcessor and what it does it seems this would be the best place to put my custom logic

We can override the TriggerPageEvent method and implement our custom processing.

The next step is for us to create our custom Processor class which extends from Sitecore’s default RegisterPageEventProcessor

After that we need to register our custom processor class in the config file. For best practice use Sitecore config file patching to do.

In our custom config file we override the default processor class to process the triggered page events with our custom processor class. Put the file in /website/app_config/include/zzz.POC/ folder

Now that we have our custom processor class and have registered it through the custom config file, we need to create the actual page event items in Sitecore.

Here’s what the created page event items looks like in my setup.


And now to test it out, browse to the external site  and open the developer console to run these javascripts

We can check the end result in MongoDB after the session has timeout


And in the Experience Profile


That’s it folks.


Sitecore 8 – Create a custom personalization rule

Sitecore OOTB comes with tons of personalization rules that we can use, however there might be times where we need to create a custom rule condition that fits to the client business requirements.

Luckily with Sitecore framework that’s known easy to extend, we can easily achieve this.

Here’s the steps to create a custom personalization rule:

1.Register the tag

First of all we need to create a new tag item under /sitecore/system/Settings/Rules/Definitions/Tags


2. Register a new rule element

Create a new element folder in /sitecore/system/Settings/Rules/Definitions/Elements


3. Create a new personalization condition rule


Here I’m creating a new rule and calling it “Specific Template Name” which will do what exactly that, checking if the current context item is based on a specific template name – not really useful in real world scenario but this post is about how to setup a custom personalization rule 🙂

In the newly created rule we need to set the Text and Type fields

Text field contains the text that we’re going to present to the content author, here’s the following text that I use

the [TemplateName, StringOperator,,compares to] represents the format of input that we want to get from the content author. It follows the following format

  • OperatorId, defines the public property of the class where we want to assign the value coming from the content author input
  • StringOperator, the built-in macro that we want to use to get the input from the user. In this case this will be a string comparation operation
  • blank, this parameter will depend on the type of macro that we use, this could be a default text value if we are using the default macro,  it could be a default start path if we’re using the Tree macro  – think of it like setting a field source when we’re building a template in Sitecore. A full list of macros can be found in /sitecore/system/Settings/Rules/Definitions/Macros
  • compares to, the last parameter is the text representation that we want to show to the content author, this value is clickable and when clicked Sitecore will display the appropriate input control based on the macro that we set on the second parameter

The Type field is the full assembly name of the custom class that we want to use to perform the logic behind this personalization rule

4. Assign our custom element default tag definition to our custom tag


Of course we  can assign our custom element tag definition to one of the existing tag under /sitecore/system/Settings/Rules/Definitions/Tags so that it will automatically appear on the content author personalization rule window however if you want to make it obvious which one is your custom ones then I recommend creating your own custom tag and assign it to that

5. Assign the tag to Conditional Rendering

The last step to make the rule visible for the content author to choose from is to assign our custom tag to one of default Rules Context folder


From the picture we’re setting the tag to the Conditional Rendering rules context which will appear when the user want to personalize a certain component, but you can also some other Rules Context folders such as FXM ones.

After we assign the tag, we can verify that the custom personalization rule is available for the content author to choose from


Here’s the class that’s responsible to evaluate the custom rule condition

The class logic is simple and not doing much for the purposes of the tutorial. In a real world scenario you can make a rule that reads from a custom database, read a configuration file, call an external API (be careful with this as it will increase page load time).

This may sound like a lot of work at first compared to just creating a custom code in the rendering or similar approach. But when we consider that we’re enabling the content author/marketers to do it by themselves and removing/minimizing the dependency towards IT, it would lessen time to market and open up more possibilities for the marketers of what they can do using the platform.


Sitecore 8 – set facebook profile picture in Experience Profile

This post will talk about how to retrieve the Facebook profile picture using Sitecore Social Connect module which it seems Sitecore 8.1 update 2 does not do it on default. Of course however we can hook into the Sitecore Social User LoggedIn event or similar to perform this.

First thing first, if you don’t know how to setup a Facebook application with Sitecore then have a read through this article. Make sure that before going through the rest of the article you are able to sign-in using Facebook and verify that the user is created (check the Sitecore User Manager) and the contact is also created in MongoDB.

The first thing you would notice after the user is created is that the Facebook profile picture is not set by default in the Experience Profile after the user registered. This is what we’re going to address.

Reading through the Sitecore documentation on logging in using a Social Network credential it seems that the process is quite straightforward. Looking at the /App_config/include/social/Sitecore.Social.config, I found that there’s a couple of events that we can hook into to add additional logic

Looks like the perfect place to put the additional logic to get the Facebook profile picture. Which I did btw

note: This is by no means production ready code.

The class above will update the current contact profile picture which is coming from their Facebook account and also a couple of other information such as name, email address, gender.

That’s it.

A couple of tips that might be useful when you want to try this on your own:

  • Set Social.Logging.TraceToLog value to true to help debugging
  • You need to disable the interest field on the user’s profile as that field has been deprecated by Facebook – this is throwing an exception which I can see in the log file. You can do this by going to Sitecore.Social.ProfileMapping.Facebook.config and disable the fb_interests field.
  • If you’re trying to test the synchronization of user profile fields from Facebook or other social network then set Social.ProfileUpdating.DaysBeforeExpiration to 0. See Sitecore documentation for reference

Issues encountered with Sitecore Azure Module

I was playing around with Sitecore Azure Module last week and would like to share my experience to get the site up and running.

I am using Sitecore 8.0 version, WFFM and EXM modules. Obviously you would need the Sitecore Azure module to help you setup the content editing and content deliry farm.

  • Sitecore 8.0 rev. 160115 (8.0 Update-7)
  • Sitecore WFFM rev. 151127 (Update-6)
  • Sitecore EXM  3.1 rev. 151213 (3.1 Update-2)
  • Sitecore Azure 8.0 rev. 150522

The target Azure setup would be

  • 1CM and 1CD server in the same data center, in my case I create the farms in the Singapore data center as it’s the closest one for me
  • Sharing the same databases for CM and CD; core, master, web, reporting. In the case of CD it will not have a reference to master and reporting
  • xDB cloud will not be used, instead MongoDB databases will be created using the free 500MB databases from

Before proceeding you would need an Azure Subscription in order to be able to create the necessary VM/Cloud Service, if you’re like me and just want to try out the Sitecore Azure Module you can sign up for a free trial for one month.


In the installing Sitecore Azure Module article above, it also explain about how to deploy to Azure to setup a Editing Farm and Delivery Farm which seems to be easy and straightforward. However I encountered some issues while trying to deploy to Azure.

Issues when deploying

Error saying that the storage account already exist in Azure



The storage account service name must be unique in Azure across subscriptions, meaning that it has to be unique not only for you and for other subscriptions in the Azure as well. To fix this you can go to /sitecore/system/Modules/Azure/[project_name]/[region_name]/Editing01/Storages/Default and update the Service Name field.


Error saying that the database server already exist


In the /sitecore/system/Modules/Azure/CampaignManagement-Evaluation/Southeast Asia/Editing01/Sql01 “Server Name” field empty the value. And then clean the unused Azure SQL database server.


Error saying that the vmsize does not exist


This is because the vm tier name has been changed by Microsoft, which originally was D3 is now has been updated to Standard_D3. To fix this you would need to update the /App_Config/AzureVendors/Microsoft.xml


With the free trial subscription you might encounter an issue when the Sitecore Azure Module tries to create the database in SQL Database S2 tier


To fix this you can temporarily change the /sitecore/system/Modules/Azure/[project-Name]/[region_name]/Editing01/Sql01/Set01/[database_name] Tier field and change it to “Basic – Basic”. This could also be caused by the database size Sitecore Azure Module requested to be created is not supported by the free trial subscription, I haven’t tested this however if you would like to try it yourself then update the /App_Config/AzureVendors/Microsoft.xml change the

to something smaller, say 100GB or 10GB


Another issue when trying to create the Cloud Service


This issue seems to be related to the siteStorageSize configuration in /App_Config/AzureVendors/Microsoft.xml. I was trying to create a D3 instance which has the default size of 180GB, reducing the value to 10GB or more seems to do the trick


Some reference links that might helps:


How to create a custom ribbon in Sitecore Content Editor

In this how to article we will learn how to create a new ribbon section in the toolbar of Sitecore Content Editor and how to use the various controls available to be used in the ribbon.

How the ribbon is structured

Let’s take for example the Home ribbon.


it consist of

  • One strip, as a container of multiple chunks such as Edit, Insert, Operations, Rename, and Sorting
  • Inside of those chunks there’s the actual buttons

In summary Toolbar -> Ribbon -> Strip -> Chunk -> Button

This is what we want to achieve in this article:


Here’s how we can do that

First step, create the new ribbon

  • switch to the core database
  • under /sitecore/content/Applications/Content Editor/Ribbons/Default create a new item with using the Reference template ({EF295CD8-19D4-4E02-9438-94C926EF5284}) and name it Custom Ribbon
  • notice that the reference template on has one field which is the Reference field, we need to pass in the item id of our next item
  • under /sitecore/content/Applications/Content Editor/Ribbons/Strips create a new item with using the Strip template ({EC6D62A5-5D00-4329-8958-8AC1AD100EBB}) and name it Custom Strip
    • in the Header field insert “Custom”
    • in the ID field insert “CustomStrip”
    • in the Access Key field insert “C”, this is useful for your content editor so that they can access the ribbon by using the ALT+C key combination
    • Copy the item id and assign it to the /sitecore/content/Applications/Content Editor/Ribbons/Default/Custom Ribbon Reference field
  • under /sitecore/content/Applications/Content Editor/Ribbons/Strips/Custom Strip create a new item with using the Reference template ({EF295CD8-19D4-4E02-9438-94C926EF5284}) and name it Small Buttons
  • under /sitecore/content/Applications/Content Editor/Ribbons/Chunks create a new item with using the Chunk template ({8F3D8F9B-2D76-4ACE-803F-35415D2B230A}) and name it Custom Chunk
    • in the Header field insert “Custom Chunk – Small”
    • in the ID field insert “CustomChunkSmall”
    • Copy the item id and assign it to the /sitecore/content/Applications/Content Editor/Ribbons/Strips/Custom Strip/Small Buttons Reference field
  • under /sitecore/content/Applications/Content Editor/Ribbons/Chunks/Custom Chunk create a new item with Small Button template ({9F62EBD5-2280-4A35-BE51-A210D831D687}) and name it Small Button
    • in the Header field insert “Small Button”
    • in the ID field insert “SmallButton”

now you can see the ribbon with your newly created button.


Seems like a long step just to get our custom ribbon showing, that’s because there need to be at least one item in the ribbon before Sitecore can display your custom ribbon

Now you get the general idea of how to create a custom ribbon on the Content Editor. After we have our custom ribbon ready we could start adding various controls to it, the available controls that we can use are

  • Small Button/Large Button
  • Small Check Button
  • Small Gallery Button/Large Gallery Button
  • Small Combo Button/Large Combo Button
  • Small Dropdown Box
  • Small Menu Combo Button/Large Menu Combo Button
  • Small Input Box
  • Panel

Let’s go through them one by one.

Small Button/Large Button


The small button or large button support an action to be triggered when the user clicks on the button. For example displaying an alert window.


How do we do that?

First let’s check the fields value for that button


In the Click field we put customribbons:alert command, Sitecore will trigger this command every time the button is clicked.

The command is registered through a separate config file

The actual command class

Nothing fancy happening in the command class, this is just to give you an idea on how to wire the whole thing.

Small Check Button/Large Check Button


The small check button support a checkbox control for the user to represent toggled/untoggled state.


The small check button fields are basically the same as the small button except that it doesn’t have the option to set an icon.

The command class for this example

Don’t forget to register the command class in the config file.

Small Gallery Button/Large Gallery Button

large-gallery-button small-gallery-button

The gallery button is a special type of button that execute a XAML application when the button is clicked, for example this demo app below


Let’s see how that can be achieved.

Here’s Large Gallery Button field values.


We have a command class which registered as customribbons:gallery

The command class is not doing anything, however we still need this command class in order for it to work.

And then we have Gallery.Demo in the Gallery field, when set Sitecore will seek any XAML application under Sitecore/Sitecore Modules folder that has the matching tag.

The XAML file has a backing class that handles the functionality of the XAML page


Small Combo Button/Large Combo Button

large-combo-button small-combo-button

The combo button support two type of event

  1. When you click on the button itself
  2. When you click on the arrow

Let’s take a look at the field values


Here’s what it will do:

  1. It will trigger the customribbons:alert when the button is clicked
  2. It will run the Gallery.Demo xaml application when the arrow is clicked

Small Dropdown Box


The small drop-down box control will basically take a string separated by a pipeline in the Items field and render it as the drop-down items


Small drop-down box field values


In the example I’ve put a pipeline character in front as the default item in the dropdown control. This control will trigger the customribbons:dropdown command.


Small Menu Combo Button/Large Menu Combo Button


Like the combo button control, the menu combo button control also support two types of event. Clicking on the button and clicking on the arrow.

The Large Menu Combo Button field values


In the Menu field it refers to the menu items created under /sitecore/content/Applications/Content Editor/Menues/Custom Menus


The control will list the items referred when the arrow is clicked

large-menu-combo-button-arrow-clickedThe menu item also support the command class to be entered in the Message field.

Small Input Box


The small input box as it’s name represent has an input text field available. When the cursor is out of focus from the control or when the enter key is pressed it will trigger the command.


The command class



Panel is a way provided for the developer if the out of the box control does not meet their need, they can create their own control then register it as a panel to be used in the ribbon.

An example of this would be the Insert chunk in the Home ribbon

insert-chunk-home-ribbonWhich we can re purpose for something else, for example


In the field values, there’s only one field which is Type where we register our custom Panel


The panel class

The source code can be found in github

And that concludes this little article.