Beispiel #1
0
 public JsonResult GetConsent()
 {
     try
     {
         Task <bool?> siteConsentProvided = ConsentInfoHelper.isConsented(Tracker.Current.Session.Contact, Sitecore.Sites.SiteContext.Current);
         if (siteConsentProvided.Result == null)
         {
             return(Json(new { error = false, consentAnswered = false, consented = false }, JsonRequestBehavior.AllowGet));
         }
         else if (siteConsentProvided.Result == true)
         {
             return(Json(new { error = false, consentAnswered = true, consented = true }, JsonRequestBehavior.AllowGet));
         }
         else if (siteConsentProvided.Result == false)
         {
             return(Json(new { error = false, consentAnswered = true, consented = false }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { error = false, consentAnswered = false, consented = false }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { error = true, errorMsg = "Msg: " + ex.Message + " || InnerException: " + ex.InnerException + " || StackTrace: " + ex.StackTrace }, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #2
0
        public JsonResult SetAccount()
        {
            string name     = Request.Form["name"];
            string email    = Request.Form["email"];
            string password = Request.Form["password"];
            string consent  = Request.Form["accountConsent"];

            try
            {
                ConsentInfoHelper consentInfoHelper = new ConsentInfoHelper();
                if (!String.IsNullOrWhiteSpace(consent))
                {
                    // Consented
                    ConsentInfoHelper.setConsented(Tracker.Current.Session.Contact, Sitecore.Sites.SiteContext.Current, true);
                    return(Json(new { error = false, consentAnswered = true, consented = true }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    // Does Not Consent
                    ConsentInfoHelper.setConsented(Tracker.Current.Session.Contact, Sitecore.Sites.SiteContext.Current, false);
                    return(Json(new { error = false, consentAnswered = true, consented = false }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { error = true, errorMsg = "Msg: " + ex.Message + " || InnerException: " + ex.InnerException + " || StackTrace: " + ex.StackTrace }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #3
0
        public override void Process(StartTrackingArgs args)
        {
            Assert.ArgumentNotNull((object)args, nameof(args));
            Assert.IsNotNull((object)Tracker.Current, "Tracker.Current");
            Assert.IsNotNull((object)Tracker.Current.Session, "Tracker.Current.Session");
            Assert.IsNotNull((object)Tracker.Current.Session.Contact, "Tracker.Current.Session.Contact");

            Task <bool?> siteConsentProvided = ConsentInfoHelper.isConsented(Tracker.Current.Session.Contact, Sitecore.Sites.SiteContext.Current);

            // Abort tracking if we do not have consent to track via XConnect
            if (siteConsentProvided.Result != true)
            {
                args.AbortPipeline();
            }
            else
            {
                // Track contact via XConnect if they provide explicit consent
                InitializeTrackerPipeline.Run(new InitializeTrackerArgs()
                {
                    CanBeRobot   = true,
                    Session      = Tracker.Current.Session,
                    IsNewContact = Tracker.Current.Session.Contact.IsNew,
                    HttpContext  = args.HttpContext
                });
            }
        }