Rebuild Analytics xDB

The Sitecore Experience Database (xDB) uses two database systems (Sql Server and Mongo DB) that need to be kept in sync to provide accurate data for Sitecore reporting applications:

  1. Mongo DB collection database stores all exprience data.
  2. SQL Server reporting database stores aggregated reporting data.

This data contains mostly information about tracking data about visitors such as online visits, contacts information (visitors), goals, campaigns, profiles, pattern cards and A/B testing.

There are different reasons to do Rebuilding of xDB and few listed below:

  1. Reporting applications are Experience profile, Experience Analytics , Experience optimization and Path Analyzer – showing improper data or No data.
  2. if data in the MongoDB collection database and Sql Server (Reporting  DB) has become out of sync.

 Rebuilding Analytics Database:

Before you start rebuilding process, our first step is to check Mongo DB and Sql Server reporting databases are connected. These database are part of standard Sitecore installation. You need to create and configure secondary reporting database

MongoDB collection database sample connection string:

<add name=”analytics” connectionString=”mongodb://localhost:27017/analytics” />
<add name=”tracking.live” connectionString=”mongodb://localhost:27017/tracking_live” />
<add name=”tracking.history” connectionString=”mongodb://localhost:27017/tracking_history” />
<add name=”tracking.contact” connectionString=”mongodb://localhost:27017/tracking_contact” />

Primary reporting database Sql Server – contains all the live data collected on your website and below is sample connection string of reporting database.

<add name=”reporting” connectionString=”user id=xxxx;password=xxxx;Data Source=(local);Database= Sitecore_Analytics” />

To connect and configure a secondary reporting database:

  1. Take clean copy of Sitecore_Analytics database from your Sitecore distribution to use as secondary reporting database.
  2. In Sql Server attach the copied database to your Sql Server instance and use name “reporting.secondary” and below is sample connection string.

<add name=”reporting.secondary” connectionString=”user id=xxxx;password=xxxx;Data Source=(local);Database=Sitecore_Reporting_Secondary” />

Now, you need to Rebuild database with below mentioned url from your browser (navigate to your Sitecore instance that is hosted in IIS):

<sitename>/sitecore/admin/RebuildReportingDB.aspx

Click on Start to begin rebuilding the reporting database.

In the Rebuilding Reporting database page, when you see Waiting to receive to data status, copy the following marketing definition tables from the primary to secondary reporting database :

  • CampaignActivityDefinitions
  • GoalDefinitions
  • OutcomeDefinitions
  • MarketingAssetDefinitions
  • Taxonomy_TaxonEntity
  • Taxonomy_TaxonEntityFieldDefinition
  • Taxonomy_TaxonEntityFieldValue

The rebuild reporting database tool provides feedback while it is processing until the rebuild process is completed.

Screenshot:

RebuildDBN

Recofigure reporting database connection strings:

In connectionstrings.config – rename your reporting.secondary database name to “reporting”, since  your newly build secondary database is your primary reporting database and comment-out original reporting connection string.