Hi Folks,
Sometimes we may get this quite generic exception:
ERROR Application error.
Exception: System.InvalidOperationException
Message: Tracker.Current is not initialized
Source: Sitecore.Analytics
at Sitecore.Analytics.Pipelines.StartAnalytics.StartTracking.Process(PipelineArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Analytics.Pipelines.StartAnalytics.StartAnalyticsPipeline.Run()
at Sitecore.Mvc.Analytics.Pipelines.MvcEvents.RequestBegin.StartTracking.Process(RequestBeginArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
at Sitecore.Mvc.Routing.RouteHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I have created this blog post to summarize all the possible reasons of this exception in one single place.
#1 Analytics host name
Look up for the mismatch of the Analytics.HostName and site host name in your Sitecore.Analytics.Tracker.config
The Analytics.HostName setting value has to match your website hostname in SiteDefinition.config file.
#2 Cluster names (Thanks to @Jose Dominguez)
If you have a load balanced environment with multiple CDs, you each server must be configured to have a unique cluster name.
This is controlled by the Analytics.ClusterName setting in the Sitecore.Analytics.Tracker.config.
<setting name="Analytics.ClusterName" value="default-cd-cluster" />
A quote from the documentation
If you are creating a cluster of content delivery servers, use your domain name when naming the content delivery cluster.
For example: value="cluster1.domain.com"
Repeat this for each node in the cluster.
For a single content delivery server, use the domain name of the server instead.
#3 Contact Facet Factory error
This usually happens when your custom facet definitions are failing to initialize, some common reasons:
- Facet class does not fully/partially implement the facet interface
You may also see the below exception in your log files:
ERROR Cannot create tracker.
Exception: System.ArgumentException
Message: The specified type is not a valid facet type.
Parameter name: facetType
Source: Sitecore.Analytics.Model
at Sitecore.Analytics.Model.Framework.ModelFactory.CreateFacet(Type facetType)
at Sitecore.Analytics.Model.Framework.Faceted.AddFacet(String name, Type type)
at Sitecore.Analytics.Model.Framework.ModelFactory.CreateContact(ID id, IReadOnlyDictionary`2 facets)
at Sitecore.Analytics.Data.ContactFactory.Create(ID id)
at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbContactStorage.TryLoadContact(ID contactId, String identifier, IContactFactory factory, LeaseOwner leaseOwner, TimeSpan leaseDuration, Int32 maxAttempts)
at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbDataAdapterProvider.TryLoadContact(ID id, IContactFactory factory, LeaseOwner leaseOwner, TimeSpan leaseDuration)
at Sitecore.Analytics.Data.ContactRepository.TryLoadContact(Guid id, LeaseOwner leaseOwner, TimeSpan leaseDuration)
at Sitecore.Analytics.Tracking.ContactManager.TryLoadContact(Guid contactId, Int32 lockDurationMinutes, Boolean exclusive)
at Sitecore.Analytics.Pipelines.EnsureSessionContext.LoadContact.Process(InitializeTrackerArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Analytics.Pipelines.EnsureSessionContext.EnsureSessionContextPipeline.Run(InitializeTrackerArgs args)
at Sitecore.Analytics.DefaultTracker.EnsureSessionContext()
at Sitecore.Analytics.Pipelines.CreateTracker.GetTracker.Process(CreateTrackerArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Analytics.Tracker.Initialize()
#4 WFFM Form is referencing a facet that can’t be initialized
This is essentially a subset of #3.
Check that your WFFM form and its save actions does not reference the unexisting contact facet! This happened to me when I eventually renamed facet, but forgot to update my form
More?
Please, feel free to comment this post and share some cases that you experienced, so that we could gather all of the related issues in one place.
Thanks