In Sitecore 8.0+, the invention of the Sitecore.Analytics.Tracker was introduced to provide Session based Analytic tracking to be sent to xDB. This is maintained in the config file Sitecore.Analytics.Tracking.config.
There are two settings:
Analytics.ClusterName
Analytics.Hostname
In a multisite configuration with multiple content delivery servers running behind a load balancer, what should the values of these settings be, in order to get Tracker to initialize appropriately?
Scenario 1:
- Sitecore Sites Config Each Site has Different Start Item:
<site name="a" hostname"aaa.com" ... EnableTracking="true" ... />
<site name="b" hostname"bbb.com" ... EnableTracking="true" ... />
<site name="c" hostname"ccc.com" ... EnableTracking="true" ... />
- 3 Content Delivery Servers
- Single IIS Site with bindings for each domain (aaa.com,bbb.com,ccc.com)
<setting name="Analytics.ClusterName" value="default-cd-cluster" />
<setting name="Analytics.HostName" value="" />
- Each domain is different from the other.
Result: Error Received Under this scenario when running Tracker.StartAnalytics()
. I get the following Stack Trace:
Tracker.Current is not initialized
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Tracker.Current is not initialized
Source Error:
Line 37: {
Line 38: if (!Tracker.IsActive)
Line 39: Tracker.StartTracking();
Line 40: }
Line 41:
Source File: D:\AgencyCode\XYZClientName-com\src\XYZClientName.Library\Abstractions\Contacts\ContactFactory.cs Line: 39
Stack Trace:
[InvalidOperationException: Tracker.Current is not initialized]
Sitecore.Analytics.Pipelines.StartAnalytics.StartTracking.Process(PipelineArgs args) +304
(Object , Object[] ) +74
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +484
Sitecore.Analytics.Pipelines.StartAnalytics.StartAnalyticsPipeline.Run() +293
XYZClientName.Library.Abstractions.Contacts.ContactFactory..ctor() in D:\AgencyCode\XYZClientName-com\src\XYZClientName.Library\Abstractions\Contacts\ContactFactory.cs:39
XYZClientName.Library.Factories.Contacts.SitecoreContactFactory..ctor() +49
XYZClientName.Library.Managers.XYZClientNameContactManager..ctor() in D:\AgencyCode\XYZClientName-com\src\XYZClientName.Library\Managers\XYZClientNameContactManager.cs:170
XYZClientName.Web.sitecore_modules.Shell.EmailCampaign.RegisterEmailOpened..ctor() in D:\AgencyCode\XYZClientName-com\web\XYZClientName.Web\sitecore modules\Shell\EmailCampaign\RegisterEmailOpened.aspx.cs:17
ASP.sitecore_modules_shell_emailcampaign_registeremailopened_aspx..ctor() +16
__ASP.FastObjectFactory_app_web_xrzs0hqx.Create_ASP_sitecore_modules_shell_emailcampaign_registeremailopened_aspx() +31
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +133
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +44
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +378
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137
Scenario 2:
- Sitecore Sites Config Each Site has Different Start Item:
<site name="a" hostname"aaa.com" ... EnableTracking="true" ... />
<site name="b" hostname"bbb.com" ... EnableTracking="true" ... />
<site name="c" hostname"ccc.com" ... EnableTracking="true" ... />
- 3 Content Delivery Servers
- Single IIS Site with bindings for each domain (aaa.com,bbb.com,ccc.com)
<setting name="Analytics.ClusterName" value="default-cd-cluster" />
<setting name="Analytics.HostName" value="aaa.com" />
- Each domain is different from the other.
Result: Tracker is initialized and working for aaa.com. Fails to load on bbb.com and ccc.com.