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();
    }
  • 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 Jan 17 '18 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. – mark DE Jong Jan 17 '18 at 14:18
  • I updated my answer to show how to update the ContactBehavior Profile on the Tracker. – Marco Jan 17 '18 at 16:27
  • You are my hero – mark DE Jong Jan 17 '18 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 – mark DE Jong Jan 24 '18 at 13:38
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;

| improve this answer | |
  • 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 – mark DE Jong Jan 17 '18 at 12:33
  • I haven't tested it yet because i'm not done updating but RemoveFromSession seems to be the solution – mark DE Jong Jan 17 '18 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 – mark DE Jong Jan 17 '18 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 – mark DE Jong Jan 18 '18 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 – mark DE Jong Jan 18 '18 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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