4

I am getting a little bit confused getting events from facets in sitecore 9.0.1.

As I understand there are two different Facet and Event class definitions. The Sitecore.XConnect version and the Sitecore.Analytics.Tracking version. The XConnect version is being used outside the session scope and the Tracking version inside.

Now i wan to get all pageviewevents for a contact from outside the session but I dont know how to get the interaction id to do this. I have lookup a lot of examples but in the examples a GUID is used and I dont know the GUID.

4

You should get a contact with expanded interactions which will contain page events.

    private async Task<IReadOnlyCollection<PageViewEvent>> GetAllPageEvents(Guid contactId)
    {
        var allInteractionsExpandOptions = new ContactExpandOptions()
        {
            Interactions = new RelatedInteractionsExpandOptions()
            {
                Limit = int.MaxValue
            }
        };
        var actualContact = await _client.GetAsync(new ContactReference(contactId), allInteractionsExpandOptions);
        List<PageViewEvent> pageEvents = new List<PageViewEvent>();
        foreach (var interaction in actualContact.Interactions)
        {
            pageEvents.AddRange(interaction.Events.OfType<PageViewEvent>());
        }

        return pageEvents.AsReadOnly();
    }
  • Would it not be very expensive to get all interactions? – Wilko van der Veen Jun 11 '18 at 9:20
  • It's interactions for a single contact, so it depends how many interactions contacts have on average. If that number turns out to be huge, then you could use search API to only get interactions by specific criteria (e.g. interactions from the last 10 days): doc.sitecore.net/developers/xp/xconnect/xconnect-client-api/… – grg Jun 11 '18 at 9:29

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.