I have the following method
GetValue()
{
var value = Tracker.Current.Contact;
}
That always executes.
However when I invoke the above method from the ItemResolver pipeline, Tracker.Current is always null.
public class CustomItemResolver : HttpRequestProcessor
{
public override void Process(HttpRequestArgs args)
{
GetValue();
}
}
What am I missing here?
Tracker is initialized during startAnalytics pipeline, which is started by the renderLayout pipeline Sitecore.Analytics.Pipelines.HttpRequest.StartAnalytics processor.
If you really need Tracker to be initialized earlier, you can use the following method:
Sitecore.Analytics.Tracker.StartTracking();
Remember that Sitecore starts Tracker much later and I'm quite sure there is a reason they don't do this before ItemResolver, so you're doing it on your own responsibility.