1

I'm using sitecore 9.1.1

I'm trying to get interaction which having key "PlanMemberId" in CustomValues and value is "test123" against this key.

I'm able to get interaction based on WebVisit facet in below code.

how can I fetch interactions based on Custom Values which added explicitly while interaction added into xDB.

using (Sitecore.XConnect.Client.XConnectClient client = Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient())
            {
var result1 = client.Interactions.Where(x => x.WebVisit().SiteName == "website").WithExpandOptions(new InteractionExpandOptions(WebVisit.DefaultFacetKey)).GetBatchEnumerator();
}
1
1

For CustomValues you need to convert them into a custom facet inside the convertToXConnectInteraction pipeline.

https://doc.sitecore.com/developers/93/sitecore-experience-platform/en/tracking-interaction-facets.html

Also: https://doc.sitecore.com/developers/93/sitecore-experience-platform/en/triggering-custom-events.html#UUID-9f9f7370-7ed1-79b5-d6a3-1416d7e4c6cf_N1560769852457

enter image description here

using Sitecore.Analytics.XConnect.DataAccess.Pipelines.ConvertToXConnectInteractionPipeline;
namespace Documentation
{
    public class ConvertInteractionFacet : ConvertToXConnectInteractionProcessorBase
    {
        public override void Process(ConvertToXConnectInteractionPipelineArgs args)
        {
            if (args != null)
            {
                var customValues = args.TrackerVisitData.CustomValues;

                var moodFacet = customValues[CustomerMood.DefaultFacetKey];

                if (moodFacet != null && moodFacet is CustomerMood)
                {
                    args.Facets.Add(CustomerMood.DefaultFacetKey, moodFacet);
                }
            }
        }
    }
}

The config

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <pipelines>
        <convertToXConnectInteraction>
            <processor patch:after="processor[@type='Sitecore.Analytics.XConnect.DataAccess.Pipelines.ConvertToXConnectInteractionPipeline.ConvertToXConnectInteractionProcessor, Sitecore.Analytics.XConnect']" type="Documentation.ConvertInteractionFacet, Documentation"/>
        </convertToXConnectInteraction>
        </pipelines>
    </sitecore>
</configuration>

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.