November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi Sanket,
You can create a custom criterion like this:
[VisitorGroupCriterion( Category = "Site Criteria", Description = "Matches if the user didn't visit a certain page", DisplayName = "Did not visit a page", LanguagePath = "/shell/cms/visitorgroups/criteria/unvisitedpages")] public class UnvisitedPagesCriterion : CriterionBase<ViewedPagesModel> { private const string SessionKey = nameof(UnvisitedPagesCriterion); public override bool IsMatch(IPrincipal principal, HttpContextBase httpContext) { var viewedPages = GetViewedPages(httpContext); if (viewedPages == null) return true; return !viewedPages.Contains(Model.GetViewedPageLink()); } public override void Subscribe(ICriterionEvents criterionEvents) { criterionEvents.VisitedPage += criterionEvents_VisitedPage; } public override void Unsubscribe(ICriterionEvents criterionEvents) { criterionEvents.VisitedPage -= criterionEvents_VisitedPage; } private void criterionEvents_VisitedPage(object sender, CriterionEventArgs e) { var pageLink = e.GetPageLink(); if (PageReference.IsNullOrEmpty(pageLink) || pageLink != Model.GetViewedPageLink()) { return; } AddViewedPage(e.HttpContext, pageLink); } private static void AddViewedPage(HttpContextBase httpContext, PageReference pageLink) { var pageReferenceSet = GetViewedPages(httpContext); if (pageReferenceSet == null) { pageReferenceSet = new HashSet<PageReference>(); if (httpContext.Session != null) { httpContext.Session[SessionKey] = pageReferenceSet; } } if (pageReferenceSet.Contains(pageLink)) { return; } pageReferenceSet.Add(pageLink); } private static HashSet<PageReference> GetViewedPages(HttpContextBase httpContext) { return httpContext.Session?[SessionKey] as HashSet<PageReference>; } }
And then define a custom visitor group like this:
Hope this helps!
...or flip logic and assign visitor group to those that visited My Pages => MyPagesVisitor.
Then create the group NotMyPagesVisitor by checking if you NOT belong to MyPagesVisitor.
Dejans solution is more fun though :)
Hi,
I am implementing Personalization on blocks and I came accross one criteria:
Show perticular block unless user does not visit "My Pages" page. So, for the first time block will appear for user unless he visits "My Page" page and then it will disappear.
How can I do that. I tried to apply Visited Page criteria combining No Of visits with Less than 1, it didnt woeked.
//Sanket Mahimkar