Loading...

Sitecore xDB - Capturing Contact Data from non-Sitecore Site - Part 2 - FXM Configuration and Review

This is part 2 of my blog series on how to capture contact data from a non-Sitecore site and import into Sitecore xDB.

In this blog I will go over setting up sample non-Sitecore site and adding it to FXM. Before we can start capturing data from a non-Sitecore site let's make sure Sitecore is properly configured and is collecting contact data in xDB. Also, please check Sitecore logs and make sure you don't have any errors there. If you do, please correct them before continuing.

Note: In case your Sitecore instance isn't working as expected or there is just too much or random things not working I recommend installing a fresh Sitecore 8.2 Update 5 instance. It will probably be much faster than trying to troubleshoot multiple issues you might have.

Let's begin

Let's keep this as simple as possible. Here is the list of steps you should do to ensure proper setup.

Step 1

Go to Sitecore Launchpad page and confirm Interactions diagram is displaying data. In case there is no data displayed here is couple of things you can do to fix it. 

Step 2

Still on Launchpad page, click on Experience Profile and confirm you already have few contacts added. For anything other than fresh Sitecore install you should see at least couple of contacts here. If you don't see any contacts go to step 3 and later go back to this page and check again.

Step 3

Let's make sure contacts are being added to xDB. Open up your Sitecore instance in a private window of your browser of choice. The following is based on private browsing in Chrome. On Sitecore page, right click on the page and select Inspect. Then go to the Application tab and expand Cookies section on the left. Confirm you have SC_ANALYTICS_GLOBAL_COOKIE and that you see 2 values in this cookie separated by "|". The first value is contact GUID.

Step 4

Sitecore is processing contacts after session ends, so take a note of the contact GUID in the cookie and close the browser. Now give Sitecore some time to process new contact and then confirm that contact has been added in mongoDB.

Step 5

Use a MongoDB management tool to confirm new contact has been added. I used Robo 3T management tool but you can use any tool you like. Keep in mind that contact GUID in mongoDB and in SC_ANALYTICS_GLOBAL_COOKIE do not match so you will have to convert the contact GUID from the cookie to bytes and then convert the bytes to a Base64String. You can read more about how to find Sitecore Contacts in MongoDB here.

In my case this is how I can confirm contact has been added in MongoDB:

  1. Contact GUID is my SC_ANALYTICS_GLOBAL_COOKIE was 79bf0a1bb85242029d50056b67db30d7
  2. Converting 79bf0a1bb85242029d50056b67db30d7 to Base64String and the value is Gwq/eVK4AkKdUAVrZ9sw1w==
  3. Search for contact in MongoDB I run the following query in Robo 3T
    db.getCollection('Contacts').find({_id:new BinData(3, 'Gwq/eVK4AkKdUAVrZ9sw1w==')})

Step 6

Make sure Sitecore has put contact in the reporting database. Fire up SQL Management Studio and check for the contact in the Contacts table. Here you will use contact GUID as is in the SC_ANALYTICS_GLOBAL_COOKIE to search for it. In my case the contact GUID was 79bf0a1bb85242029d50056b67db30d7

Step 7

So far so good. We have confirmed Sitecore is setup correctly and is collecting anonymous contact data as it should. Finally, one more thing before we move on to setting up non-Sitecore site in FXM.

To avoid Sitecore locking a contact go ahead and update following 2 settings in the Sitecore.Analytics.Tracking.config file


<setting name="Analytics.ClusterName" value="sitecore" />
<setting name="Analytics.HostName" value="sitecore" />

You can read more about these settings and why are we doing this here.

Step 8

Next up, setting up sample non-Sitecore site in your environment. For the purposes of these blog series please use the sample non-Sitecore site provided in the solution on GitHub.

Do the following to setup the sample non-Sitecore site in your environment:

  1. In wwwroot folder create a new folder xdbcc.sites.nonsitecore (this is where non-Sitecore site will live)
  2. Create new site in IIS with these settings:

  3. Update hosts file to include the following line:
    127.0.0.1              xdbcc.sites.nonsitecore
  4. Get the code from GitHub and publish xDBCC.Sites.nonSitecore project.
  5. Open browser and type http://xdbcc.sites.nonsitecore and confirm you see the following page.
  6. Sample non-Sitecore site has been successfully setup

Step 9

Add sample non-Sitecore site to FXM. You can read how to do this here.

Basically, you need to create a new site in FXM and then add generated script tag to the non-Sitecore site. My local Sitecore instance is setup for xdbcontactcapture.local so in my case I added following code to the Shared _Layout.cshtml view:

Tip: After you add site in FXM make sure you don't forget to publish it.

Step 10

Make sure everything is wired up correctly and contacts are being added from sample non-Sitecore site to xDB. Go back and repeat steps 3-6 but this time using sample non-Sitecore site and checking for sc_ext_contact cookie instead of SC_ANALYTICS_GLOBAL_COOKIE to get contact GUID. Why sc_ext_contact and not SC_ANALYTICS_GLOBAL_COOKIE you ask? This will be explained later, for now, don't worry about it too much :)

Code

All code is available in my GitHub repository.

Summary

In this blog we setup sample non-Sitecore site and made sure Sitecore xDB is collecting contact data on both Sitecore instance itself and on non-Sitecore site that has been added to FXM.

In next blog we are going to go though steps to actually collect contact data from sample non-Sitecore site and update anonymous xDB contacts.

Disclaimer
This is a personal blog. The opinions expressed here represent my own and not those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.. In addition, my thoughts and opinions change from time to time I consider this a necessary consequence of having an open mind. This blog disclaimer is subject to change at anytime without notifications.