3

After enabling the Sitecore 9 analytics, when I open the Experience Profile, I see all the WebApi ajax calling as page view events or page events in the Experience Profile.

Why this is happening?

Is there any way to prevent that?

BTW, in our system, session is enabled for WebApi calls.

3

The best way to tackle this is to add an Action Filter on your Controller actions to prevent the events from showing up in your Analytics Reports.

Filter code:

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public sealed class DisableTrackingAttribute : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        if (!Tracker.IsActive || Tracker.Current == null)
        {
            Tracker.StartTracking();
        }

        if (Tracker.Current != null && Tracker.Current.CurrentPage != null)
        {
            Tracker.Current.CurrentPage.Cancel();

            base.OnActionExecuting(filterContext);
        }
    }
}

Example Controller code:

[ServicesController]
public class AnalyticsController : ServicesApiController
{
    [HttpPost]
    [DisableTracking]
    public dynamic TriggerPageEvent(string eventId, string setUrl = null)
    {
        Some logic
    }
}
  • Hi, thanks for you reply. I found my solution through your answer. Although I implemented it using pipeline. – Foysal Jun 4 '18 at 9:07
0

Take a look on page event settings for "Page Visit":

https://doc.sitecore.net/sitecore_experience_platform/digital_marketing/experience_profile/configuring_the_xfile/configure_a_page_event_to_appear_in_the_experience_profile

I think that if you modify "Rules" field you can filter out traffic to web api.

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.