This repository contains code for displaying Gravatars in the Sitecore Experience Profile that Rick Bauer and I demonstrated in our JavaScript Services & Marketing Automation and Crank Up Your Sitecore Authoring and Marketing Experience presentations.
There are two ways to integrate Gravatar with the Experience Profile:
- Override the
IContactService
that the Experience Profile uses to retrieve the contact's Gravatar on page load; and/or - Write to the contact's
Avatar
facet at some point in their journey with your website (see the warning below!).
The first option will add Gravatar to all contacts in the Experience
Profile as it does not require you to write to the Avatar
facet of your
contacts. The second option makes the contact's Gravatar available
anywhere you use the Avatar
facet in your site.
At a minimum I recommend implementing the first option in your Sitecore solutions. The second option is nice for new Sitecore installs, but probably not practical for existing solutions with lots of existing contacts. Both options are compatible with each other.
See the code in the Experience Profile feature module to see how you can
integrate a GravatarService
into the IContactService
to load the
Gravatar for all contacts in the Experience Profile that don't have the
Avatar
facet set.
See the code in the ContactRepository
of the Website project module
to see how to set the Avatar
facet on contacts using Gravatar.
There is a bug in the xConnect Index Worker in Sitecore 9.1 and above that
causes it to fail and stop indexing any contacts if images above a certain
size are written to the Avatar
facet. New contacts will not show up in the
Experience Profile until the offending Avatar
facet is removed from the data
store (e.g., SQL Server).
To fix this issue, set the StringFieldMaximumLength
to a value that is
divisible by 4
in the xConnect Indexer Worker's config as I've done in
sc.Xdb.Collection.Search.IndexTruncation.xml
and deploy it to your
xConnect Index Worker in all environments.
No matter what precautions you take (e.g., downsizing images, compressing
images), if you write to the Avatar
facet in xConnect you are going to be
affected by this issue. DO NOT write to the Avatar
facet (using
Gravatar or otherwise) in Sitecore 9.1 or above without applying this fix
first.
- Build the Sitecore 9.3 docker images using the steps in the Sitecore Docker images repository.
- Build the solution with the
Docker
build configuration. - All projects in the solution will be automatically published to Docker on build courtesy of Helix Publishing Pipeline.
- On the command line:
cd C:\[path-to]\sitecore-experience-profile-gravatar
docker-compose up
- Install a new instance of Sitecore 9.3.
- Update the
publishUrl
inPublishSettings.Sitecore.targets
to your Sitecore installation's web root (e.g.,C:\inetpub\wwwroot\sc93.sc
). - Update the
publishUrl
inPublishSettings.XConnectIndexer.targets
to your Sitecore installation's xConnect Indexer Worker root (e.g.,C:\inetpub\wwwroot\sc93.xconnect\App_Data\jobs\continuous\IndexWorker
). - Update the
sourceFolder
inCoreyAndRick.Project.Common.Dev.config
to point to the root of this repository on your disk. - Build the solution with the
Debug
build configuration. - All projects in the solution will be automatically published to Sitecore on build courtesy of Helix Publishing Pipeline.