I'm trying to disable/remove the SC_ANALYTICS_GLOBAL_COOKIE based on an opt in cookie.
I have updated the Sitecore.Analytics.Tracking.config to add a custom extension to disable analytics and delete cookie. But that does not seems to be working even though the code is hitting my cookie check and removing the cookie
<processor type="Sitecore.Analytics.Pipelines.StartAnalytics.CheckPreconditions, Sitecore.Analytics" />
<processor type="SC.Web.SitecoreExtensions.Pipelines.Analytics.CheckCookie, SC.Web.SitecoreExtensions" patch:after="processor[@type='Sitecore.Analytics.Pipelines.StartAnalytics.CheckPreconditions, Sitecore.Analytics']" />
Cookie Checking Class:
public class CheckCookie
{
public void Process(PipelineArgs args)
{
if (!CheckCookieAccepted(HttpContext.Current.Request))
{
Sitecore.Analytics.Tracker.Enabled = false;
args.AbortPipeline();
DeleteAnalyticsCookie();
}
}
private void DeleteAnalyticsCookie()
{
HttpCookie analyticsCookie = HttpContext.Current.Request.Cookies["SC_ANALYTICS_GLOBAL_COOKIE"];
if (analyticsCookie != null && !string.IsNullOrEmpty(analyticsCookie.Value))
{
HttpContext.Current.Response.Cookies.Remove("SC_ANALYTICS_GLOBAL_COOKIE");
analyticsCookie.Expires = DateTime.Now.AddDays(-10);
analyticsCookie.Value = null;
HttpContext.Current.Response.SetCookie(analyticsCookie);
}
}
}
Is there any place else I should be doing this check? Which exact Analytics pipeline step is creating this cookie?