As I'm new to Profile cards and pattern cards so gone through multiple blogs on How to associate Profile and pattern cards to a Sitecore item. I've a scenario when user visits Home page 2 times and Registration page 3 times I want my profile to be matched As FrequentRegisterUser?

How this can be done in Sitecore and please include the reference if available?

Edit :

As per above descriptions I am elaborating it in more detailed and simple words

I've below three pages and If user visits the following journey


based on given visit number for specific page(Item)

Home(visitcount:1)->Hotels(visitcount:4)->Booking page(visitcount:1) I want my pattern to be matched as Holiday Visitor

profile snippet**strong text**

Cannot I achieve above using built in rules or conditions in sitecore? If not, What would be alternative approach to achieve it. Do I need to create custom rule condition?

Any help or suggestion would be greatly appreciated.

Thanks & Regards,

  • You are going to need a custom Sitecore rule that will look back in the user's behavior cache and count the page counts for a specific page.
    – Chris Auer
    Commented Oct 16, 2018 at 15:54
  • @chris Thankyou. Could you please help me getting some examples link if available? Commented Oct 17, 2018 at 4:48
  • 1
    Creating custom rule in sitecore for matching pattern based on the page specific count Does it require any custom code to be written or it can done via sitecore ? Commented Oct 17, 2018 at 5:11
  • Let me write you come code
    – Chris Auer
    Commented Oct 18, 2018 at 1:59

1 Answer 1


I am making the assumption that you want to know if they have visited the home and registration page or any past visit. Not just the current visit. The page history of the user is kept in the Key Behavior Cache. But the KBC does not contain pages. But it does contain past page events and goals.

To create a page event, go to the item /sitecore/system/Settings/Analytics/Page Events and create two new events. One for home page visit and one for registration page visit. Note the item IDs for each of these events.

Then on the home page, assign the home page visit event. On the registration page assign the registration page visit. You assign events in the image below.

enter image description here

Just to revisit how profiles work in Sitecore:


template: /sitecore/templates/System/Analytics/Profile

This is the container for a profile. In you image, this is Holiday Visitor

Profile Key

template: /sitecore/templates/System/Analytics/Profile Key

This is an individual scoring item for a pattern card. Remember in the end you are looking to trigger pattern cards. The profile key is a vehicle for scoring to trigger a pattern card.

Profile Card

template: /sitecore/templates/System/Analytics/Profile Card - Persona

This is a preselected set of profile keys and values. A profile card is a great thing because setting each key and value on each item would take forever. And then making a change would take for ever. By using a profile card, you are assigning a profile card to an item. One stop shopping.

Your Holiday Visitor profile card should have enough value to trigger the Holiday Visitor pattern card.

Pattern Card

template: /sitecore/templates/System/Analytics/Patterns/Pattern Card

A pattern card is the prize at the end. When you trigger enough profile keys to a certain value level, the pattern is assigned to the user. This is what you personalize on.

ProcessItem Pipeline

The technique I am going to use here it to check to see if the user has compiled enough page events for the home page (2) and registration page (3). If they have, we are going to send a profile card into the TrackingFieldProcessor.ProcessProfiles() function to trigger the pattern card.

This code is untested, but it should get you to where you need to be. You could also make this much more dynamic by using rules. But I thought rules would make this code more confusing. You can look at this repo to see how to use rules and profile items. https://github.com/buildabonfire/rule-based-profile-cards

namespace Sitecore.Feature.PersonalizationRules.Pipelines.ProcessItem
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Sitecore.Analytics;
    using Sitecore.Analytics.Data;
    using Sitecore.Analytics.Pipelines.ProcessItem;
    using Sitecore.Analytics.Tracking;
    using Sitecore.Data;
    using Sitecore.Data.Items;
    using Sitecore.Diagnostics;

    public class ProcessItemForProfiles : ProcessItemProcessor
        // this is profile card value field on the profile card template.
        public static ID ProfileCardValue = new ID("{85970AB7-22EA-4206-BE86-C0167178860B}");

        public override void Process(ProcessItemArgs args)
            Assert.ArgumentNotNull((object)args, "args");

            var registrationPageEventGuid = new Guid("ID For Registration Page Event");
            var homePageEventGuid = new Guid("ID For Home Page Event");

            // lets check to see if we have enough events and lets see if the user is already in the "Holiday Visitor" profile.
            if (IsPageEventCount(registrationPageEventGuid, 3) 
                 && IsPageEventCount(homePageEventGuid, 2) 
                 && !Tracker.Current.Interaction.Profiles.ContainsProfile("Holiday Visitor"))
                var profileItem = Sitecore.Context.ContentDatabase.GetItem(new ID("ID to the profile card"));

        private bool IsPageEventCount(Guid pageEventId, int count)
            var pageEvents = Tracker.Current.Session.Interaction.Pages.SelectMany(x => x.PageEvents).Where(x => !x.IsGoal);
            var sessionCount = pageEvents.Count(x => x.PageEventDefinitionId == pageEventId);
            var kbcCount = Tracker.Current.Session.Contact.GetKeyBehaviorCache().PageEvents.Count(x => x.Id == pageEventId);

            return (sessionCount + kbcCount) > count;

        private static void ProcessProfile(BaseItem profileItem)
            var isActive = Tracker.Current != null && Tracker.Current.IsActive;
            if (!isActive) return;

            var trackingFields = new List<TrackingField>
                new TrackingField(profileItem.Fields[ProfileCardValue])

            var fields = (IEnumerable<TrackingField>)trackingFields;

            var interaction = Tracker.Current?.Session?.Interaction;
            if (interaction == null) return;

            TrackingFieldProcessor.ProcessProfiles(interaction, fields.FirstOrDefault());

The config

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
                <processor type="Sitecore.Feature.PersonalizationRules.Pipelines.ProcessItem.ProcessItemForProfiles, Sitecore.Feature.PersonalizationRules"
                           patch:after="processor[@type='Sitecore.ExperienceExplorer.Business.Pipelines.ProcessItem.ProfilesPipeline, Sitecore.ExperienceExplorer.Business']"></processor>
  • Thankyou @Chris for valuable information and support, Will definitely try it out. A small question Does above also work for frequent visit of pages ? Commented Oct 18, 2018 at 5:59
  • The code IsPageEventCount() is checking for the frequent visit of pages. Its checks for the count.
    – Chris Auer
    Commented Oct 18, 2018 at 11:53

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.