4

I have the below situation.

I have a .NET Core application that sends a Contact with Facet data to xConnect to show interest in a category (using profile keys).

A Sitecore website, on which I track a Contact, to show a commercial based on interest shown in the category.

It worked first time when I tried, i got the commercial that i was expecting. Than i updated my profile keys again in my .NET Core application, and i can see my ContactBehaviourProfile being updated to the new interest.

However, when i log into the Sitecore website and start tracking the Contact with changed interests, the commercial from the first setting poped up.

I have my rules set up like this: Rules

I don't have much experience with Sitecore but heard somewhere that Contact data is flushed to xDB when session ends,

Does Sitecore 9/ xConnect have the same behaviour?

EDIT:
I tried updating and using the RemoveFromSession method. I am now calling the method before returning the view but i am still getting the old Contact.

    [HttpPost]
    public ActionResult Track(string email)
    {
        if (Request.Form["Email"] != null)
        {
            if (Request.Form["Email"] != "")
                Tracker.Current.Session.IdentifyAs("email", Request.Form["email"]);
        }
        var contact = Tracker.Current.Session.Contact; // this is for debugging
        Sitecore.XConnect.Contact Contact = GetContactWithBehaviourProfile(email); // this is for debugging
        FillViewBag();
        var manager = Sitecore.Configuration.Factory.CreateObject("tracking/contactManager", true) as Sitecore.Analytics.Tracking.ContactManager;
        manager.RemoveFromSession(Sitecore.Analytics.Tracker.Current.Contact.ContactId);
        return View();
    }
10
  • Could u upgrade to v9 update 1 and release the contact so that any facets get reloaded on next request without you needing tok update the trackers contact manually?
    – Marco
    Commented Jan 17, 2018 at 14:17
  • I was going to try that but i have little experience with updating Sitecore or with Sitecore at all for that matter so i'm a little hesitant. Commented Jan 17, 2018 at 14:18
  • I updated my answer to show how to update the ContactBehavior Profile on the Tracker.
    – Marco
    Commented Jan 17, 2018 at 16:27
  • You are my hero Commented Jan 17, 2018 at 16:30
  • I have tried updating to Sitecore v9 update 1 and added the code to remove the Contact from session, however this has not solved my issue. After restarting my server the Contact in the Tracker is updated but the manager.RemoveFromSession() method does not seem to work Commented Jan 24, 2018 at 13:38

1 Answer 1

4

SC 9 is flushed immediately unlike previous versions. With your particular issue, my guess is that you didn't update the Tracker's Contact (assuming that you are doing this on the same tracker session). This means that updating the xConnect Contact does not automatically update the Tracker's Contact. This is mainly true on v. 9 Initial Release. So, you must update your Tracker's Contact also when updating xConnect's Contact. However, in v9 Update 1, Sitecore has provided a new Sitecore.Analytics.Tracking.ContactManager method :

manager.RemoveFromSession(Sitecore.Analytics.Tracker.Current.Contact.ContactId); // Use tracker ID, not xConnect ID

to allow the contact to be reloaded in next request. Find out more here.

UPDATE

Here's how to access the ContactBehaviorProfile facet as shown in the Sitecore Docs. At this point, you should just be able to update the data but of course it depends how much data you need to update, it may get a bit more complex.

var xConnectFacets = Sitecore.Analytics.Tracker.Current.Contact.GetFacet("XConnectFacets");

ContactBehaviorProfile cbp = xConnectFacets.Facets[ContactBehaviorProfile.DefaultFacetKey] as ContactBehaviorProfile;

6
  • I fill the Facets from a .NET Core application so i don't think this is the issue, i will be taking a look at the ContactManager tho Commented Jan 17, 2018 at 12:33
  • I haven't tested it yet because i'm not done updating but RemoveFromSession seems to be the solution Commented Jan 17, 2018 at 15:24
  • I'm getting the following error :'TFacet' does not contain a definition for 'Facets' and no extension method 'Facets' accepting a first argument of type 'TFacet' could be found (are you missing a using directive or an assembly reference? i believe it wants me to specify the specific Facet, i tried ContactBehaviorProfile and IContactBehaviorProfiles. neither worked Commented Jan 17, 2018 at 22:16
  • Turns out i was missing the Sitecore.Analytics.XConnect.dll`and i had to specifiy IXConnectFacets between brackets with the GetFacet method Commented Jan 18, 2018 at 10:47
  • One more problem, the ContactBehaviorProfile is saved in a Facet but is also a property of Contact called BehaviorProfiles, i believe the property is actually used by sitecore because updating the Facet in memory did not do anything. I tried editing the property but i can't seem to figure out how to convert the xConnect ContactBehaviorProfile to the BehaviorProfiles property Commented Jan 18, 2018 at 11:44

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.