Tuesday, March 19, 2019

Analytics “Tracker.Current is not initialized”

Analytics “Tracker.Current is not initialized”

  1. Analytics config needs (from thread below) to be present on each CM and CD server
  2. In this config across all servers you should have “cd.cluster.igt.com” as the cluster name (so hostname, not IP)
  3. On CM: make a hosts file entry for cd.cluster.igt.com to be pointing to one of the CD server’s IP (not load balancer)
  4. On CD: make sure cd.cluster.igt.com hosts file entry points to itself (127.0.0.1)
  5. If the site on the subdomain that you mentioned uses the same codebase and the same config then no additional changes are necessary. It should be handled through the changes mentioned above. 



https://sitecore.stackexchange.com/questions/4431/analytics-tracker-current-is-not-initialized/4433

Cannot Create Tracker or Tracker.Current is Not Initialized - Common Fixes

Your problem is that after changing the Analytics.Clustername, you are not ensuring that the hostname (which is really what ClusterName is) is resolvable. All Servers must be able to resolve the ClusterName by DNS. Either by a host file entry locally on the server or through a DNS server.
See http://default-cd-cluster/sitecore/service/analytics/session/PushSession.ashx, unless default-cd-cluster is defined somewhere on your local host file or DNS, default-cd-cluster does not resolve. On CD instances, this has to resolve to local host (127.0.0.1), but on CM's this has to resolve to a CD instance IP address.
By the way, in single instance mode, where CM and CD are combined, I almost never change the ClusterName from defaults, because it'll work just fine. User of Analytics.ClusterName is only super important in a distributed role environment (separated CM and CD's).
See Below for insight and details on why this is occurring and how to fix it.

Reason 1: Analytics.ClusterName is configured incorrectly.

The Analytics.ClusterName which is set in the Sitecore.Analytics.Tracking.config needs to be a legitimate, resolvable hostname. The default "default-cd-cluster" is not enough to promote a working solution. This value has to be a dns name that all Sitecore Servers can reach (e.g. cd.cluster.domain.com for example).
  • Ensure that each server, at a minimum has the configured Analytics.ClusterName in the windows host file and configured to point to an IP address of a Content Delivery server.
    • If on a content delivery server, set this host file IP equal to localhost, which is 127.0.0.1.
    • If on a content management or other server, set the host file IP value equal to the IP of ONE of your CD servers. Do not set it to the load balancer IP (unless that can be reached by your network)

Reason 2: Analytics.Hostname is Incorrect

It has been my experience that setting a value for Analytics.Hostname, located in the Sitecore.Analytics.Tracking.config file does more harm than good. I have found leaving this value BLANK, makes everything work as it should.

Reason 3: Sitecore.Context.Page is not available.

Sitecore's Analytic Tracker requires that the Sitecore.Context.Page object be available in order for Tracker to be initialized. In certain cases where this object is not available, and Tracker tries to be started, it will throw this error.
Tracker cannot be utilized on ASHX's, internal pipelines or thread processes where Page is not set.

Utilization of Tracker on Content Management Servers.

Pure (role configured) Content Management servers do not utilize session state management, and therefore can not run Tracker natively. Instead, they rely on the Analytics.ClusterName to resolve in order to communicate a session back to the Content Delivery servers. In cases where on the Content Management server, you receive these types of errors, it is because Analytics.ClusterName is not correctly setup and reachable.
This also applies to Processing ServersEXM Dispatch Servers, and Secondary Content Management Servers.

Want a Deep Dive Look?

Here is a link to a blog post that I just published today as a result of this answer. In addition, I go into a deep dive behind the covers to reveal what's really going on when the Tracker is initialized and WHY the Analytics.ClusterName is so important.

No comments:

Post a Comment