Category Archives: Social Connect

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