1

Does anybody recognize this error: "this.Interaction should not be null".

It occurs on our server when we execute

Sitecore.Analytics.Tracker.Current.Session.IdentifyAs(source, identifier);

The request is executed as an Ajax request to a mvc-controller. Identifier is an email address.

Previously we have checked that the tracker is active and running by:

public static bool IsActive
    {
        get
        {
            if (Sitecore.Analytics.Tracker.Enabled == false)
            {
                return false;
            }
            if (Sitecore.Analytics.Tracker.Current == null)
            {
                Sitecore.Analytics.Tracker.StartTracking();
            }
            if (Sitecore.Analytics.Tracker.Current != null && !Sitecore.Analytics.Tracker.Current.IsActive)
            {
                Sitecore.Analytics.Tracker.StartTracking();
            }
            return true;
        }
    }

1 Answer 1

1

Tracker and Identify require an HTTP PageSession context exists in order to work. AJAX calls to establish a different context and does not create a PageContext. This is why you are finding that Tracker is already null and trying to start it.

When you StartTracking() it will start Tracker with a different contact id but not create the Interaction.

You can't Identify in an AJAX call.

Use a Controller Rendering to perform the Identify.

For more in-depth information about common Tracker issues and a deep dive on this, reference https://sitecorehacker.com/2017/02/12/sitecore-analytics-tracker-common-issues-and-how-to-resolve-them/

3
  • I've successfully identified on both a MVC controller and a web api controller (session enabled) during an AJAX call. I can do identifyAs successfully on my local dev server and our test environment. The error only occurs on our production server...
    – Johan
    Commented Oct 1, 2018 at 15:33
  • Does the Contact Cookie get updated appropriately coming out of the ajax call? Maybe something has changed in 9.0.2 architecture. As for your production environment, if an issue is only occurring on one environment, it's generally a configuration issue or something to do with the fact that you're environment is scaled out more, than running in a standalone instance. Tracker doesn't work on the Content Management server as an example.. It's meant to only run on the CD server. Commented Oct 1, 2018 at 16:29
  • Are you referring to the cookie "SC_ANALYTICS_GLOBAL_COOKIE" ? I can't see that it's updated after the ajax request has finished. What kind of update should I expect?
    – Johan
    Commented Oct 3, 2018 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.