コード例 #1
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
                });
            }
        }
コード例 #2
0
        public override void Process(StartTrackingArgs args)
        {
            if (!Tracker.IsActive || String.IsNullOrEmpty(RulesItemId))
                return;

            VisitorDataSet.VisitsRow currentVisit = Tracker.Visitor.GetCurrentVisit();

            if (currentVisit == null || currentVisit.HasGeoIpData)
                return;

            Item rulesItem = Sitecore.Context.Database.GetItem(RulesItemId);

            if (rulesItem == null)
                return;

            RuleList<RuleContext> ruleList = RuleFactory.GetRules<RuleContext>(rulesItem, "Rule");

            if (ruleList == null)
                return;

            RuleContext ruleContext = new RuleContext();

            if (SatisfiesConditions(ruleList, ruleContext))
                currentVisit.UpdateGeoIpData();

            ruleContext.Abort();
        }
コード例 #3
0
 public void Process(StartTrackingArgs args)
 {
     if (Tracker.CurrentVisit != null)
     {
         //Alle Daten des Besuchers werden geladen, sofern Cookie vorhanden. Dadurch sind bereits getrackte Profile wieder present!!!
         Visitor visitor = Sitecore.Analytics.Tracker.Visitor;
         visitor.LoadAll();
     }
 }
コード例 #4
0
        /// <summary>
        /// Process the pipeline step
        /// </summary>
        /// <param name="args"></param>
        public void Process(StartTrackingArgs args)
        {
            // bail out if null
            if (Tracker.CurrentVisit == null || Tracker.CurrentVisit.Ip == null)
            {
                return;
            }

            // get current raw IP
            string ip = new IPAddress(Tracker.CurrentVisit.Ip).ToString();
            Assert.IsNotNullOrEmpty(ip, "Tracker.CurrentVisit.Ip");

            // default BadIps if not set
            if (string.IsNullOrEmpty(BadIps))
            {
                BadIps = "0.0.0.0|127.0.0.1";
            }

            // if the currently tracked IP is not in the list of
            // bad IPs, don't bother processing the IP override
            if (!BadIps.Split('|').Contains(ip))
            {
                return;
            }


            string rawIpValue = "";

            if (string.IsNullOrEmpty(MockIp))
            {
                if (string.IsNullOrEmpty(IpUrl))
                {
                    // no mock IP or WAN IP lookup URL
                    return;
                }
                else
                {
                    // fetch WAN IP via IP lookup URL
                    rawIpValue = Sitecore.Web.WebUtil.ExecuteWebPage(IpUrl);
                    Assert.IsNotNullOrEmpty(rawIpValue, "WAN IP lookup from <IpUrl>");
                }
            }
            else
            {
                // mock IP is configured so use it
                rawIpValue = MockIp;
                Assert.IsNotNullOrEmpty(rawIpValue, "value of <MockIp>");
            }

            // sanitize raw IP value
            rawIpValue = rawIpValue.ToLowerInvariant().Replace("\n", "").Replace("\r", "");

            // convert IP and set to current visit
            IPAddress address = IPAddress.Parse(rawIpValue);
            Tracker.CurrentVisit.GeoIp = Tracker.Visitor.DataContext.GetGeoIp(address.GetAddressBytes());
        }
コード例 #5
0
 public void StartTracking()
 {
     if (IsActive)
     {
         Log.Debug("Skipping of tracking, tracker is already active", (object)typeof(Analytics.Tracker));
     }
     else if (!Sampling.IsSampling())
     {
         Log.Debug("Session is null or the session is not participate in analytics because was not chosen as a sample for tracking", (object)typeof(Analytics.Tracker));
     }
     else
     {
         SiteContext site = Sitecore.Context.Site;
         if (site != null && !site.Tracking().EnableTracking)
         {
             Log.Debug("Cannot start tracking, analytics is not enabled for site " + site.Name, (object)typeof(Analytics.Tracker));
         }
         else if (ExcludeRequest())
         {
             Log.Debug("The request was excluded because the Agent or IP is determined as a robot, see Exclude robots configuration file", (object)typeof(Analytics.Tracker));
             AnalyticsTrackingCount.CollectionRobotRequests.Increment(1L);
         }
         else if (IgnoreCurrentItem())
         {
             AnalyticsTrackingCount.CollectionRequestsIgnored.Increment(1L);
         }
         else
         {
             IsActive = true;
             StartTrackingArgs args = new StartTrackingArgs()
             {
                 HttpContext = new HttpContextWrapper(HttpContext.Current)
             };
             try
             {
                 StartTrackingPipeline.Run(args);
             }
             catch (ThreadAbortException ex)
             {
                 throw;
             }
             catch (Exception ex)
             {
                 this.IsActive = false;
                 if (!AnalyticsSettings.SuppressTrackingInitializationExceptions)
                 {
                     throw new Exception("Failed to start tracking", ex);
                 }
                 Log.Error("Cannot start analytics Tracker", ex, typeof(Analytics.Tracker));
             }
         }
     }
 }
コード例 #6
0
        public override void Process(StartTrackingArgs args)
        {
            Sitecore.Diagnostics.Assert.IsNotNull(Tracker.Current, "Tracker.Current is not initialized");
            Sitecore.Diagnostics.Assert.IsNotNull(Tracker.Current.Session, "Tracker.Current.Session is not initialized");

            if (Tracker.Current.Session.Interaction == null)
            {
                return;
            }

            if (IsMockEnabled)
            {
                var mockWhoIsInformation = MockLocationFallbackManager.MockLocationFallbackProvider.GetMockCurrentLocation();
                Tracker.Current.Session.Interaction.SetGeoData(mockWhoIsInformation);
                return;
            }

            var ip       = GeoIpManager.IpHashProvider.ResolveIpAddress(Tracker.Current.Session.Interaction.Ip);
            var stringIp = ip.ToString();

            if (Tracker.Current.Session.Interaction.CustomValues.ContainsKey(stringIp) && UpdateGeoIpDataOverrided(ip))
            {
                Sitecore.Diagnostics.Log.Debug("GeoIPFallback: the fallback version is overrided by data from Sitecore GEO IP service.", this);
                Tracker.Current.Session.Interaction.CustomValues.Remove(stringIp);
                return;
            }

            if (!Tracker.Current.Session.Interaction.UpdateGeoIpData())
            {
                try
                {
                    Sitecore.Diagnostics.Log.Info("GeoIPFallback: Current location was not resolved by Sitecore GEO IP service; Local MaxMind database is requested. IP: " + stringIp, this);

                    var whoIsInformation = LocationFallbackManager.LocationFallbackProvider.Resolve(ip);

                    Tracker.Current.Session.Interaction.SetGeoData(whoIsInformation);
                    Tracker.Current.Session.Interaction.CustomValues.Add(stringIp, whoIsInformation);
                }
                catch (Exception ex)
                {
                    Sitecore.Diagnostics.Log.Error("UpdateGeoIpData: Something was wrong.", this);
                    Sitecore.Diagnostics.Log.Error("Exception:", ex, this);
                }
            }
        }
コード例 #7
0
        public override void Process(StartTrackingArgs args)
        {
            var item  = Sitecore.Context.Item;
            var args2 = new GetSourceItemsArgs(item);

            CorePipeline.Run("contentTracker.getSourceItems", args2);
            var sourceItems = args2.SourceItems;

            if (sourceItems == null)
            {
                return;
            }
            var visit = Tracker.Visitor.GetOrCreateCurrentVisit();

            foreach (var sourceItem in sourceItems)
            {
                ContentTrackingManager.ApplyTracking(sourceItem);
            }
        }
コード例 #8
0
        /// <summary>
        /// Processes the specified args.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public override void Process(StartTrackingArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

              string ecommerceEvent = WebUtil.GetQueryString(Settings.GetSetting("Ecommerce.Analytics.EventQueryStringKey")).Trim();
              if (string.IsNullOrEmpty(ecommerceEvent))
              {
            return;
              }

              if ((ecommerceEvent.ToLowerInvariant() != null) && (ecommerceEvent == "followlist"))
              {
            AnalyticsUtil.NavigationFollowListHit();
              }
              else
              {
            AnalyticsUtil.RegisterNoParameterEvent(ecommerceEvent);
              }
        }
コード例 #9
0
        /// <summary>
        /// Processes the specified args.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public override void Process(StartTrackingArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            string ecommerceEvent = WebUtil.GetQueryString(Settings.GetSetting("Ecommerce.Analytics.EventQueryStringKey")).Trim();

            if (string.IsNullOrEmpty(ecommerceEvent))
            {
                return;
            }

            if ((ecommerceEvent.ToLowerInvariant() != null) && (ecommerceEvent == "followlist"))
            {
                AnalyticsUtil.NavigationFollowListHit();
            }
            else
            {
                AnalyticsUtil.RegisterNoParameterEvent(ecommerceEvent);
            }
        }
コード例 #10
0
        public override void Process(StartTrackingArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            var item = Sitecore.Context.Item;

            if (item == null)
            {
                return;
            }
            var rules = GetProfilingRules(item);

            if (rules == null || rules.Count == 0)
            {
                return;
            }
            var visit   = Tracker.Visitor.GetOrCreateCurrentVisit();
            var context = new TrackingRuleContext(item, visit);

            context.Item = item;
            rules.Run(context);
        }
コード例 #11
0
ファイル: OverrideIPAddress.cs プロジェクト: Praveencls/cxm
        public void Process(StartTrackingArgs args)
        {
            //if (Tracker.CurrentVisit == null || Tracker.CurrentVisit.GeoIp == null || Tracker.CurrentVisit.Ip == null)
            if (Tracker.CurrentVisit == null || Tracker.CurrentVisit.Ip == null)
            {
                return;
            }

            //string ip = new IPAddress(Tracker.CurrentVisit.GeoIp.Ip).ToString();
            string ip = new IPAddress(Tracker.CurrentVisit.Ip).ToString();

            if (ip != "0.0.0.0" && ip != "127.0.0.1")
            {
                return;
            }

            string rawIpValue = "";

            if (Ip.IsNullOrEmpty())
            {
                if (IpUrl.IsNullOrEmpty())
                {
                    return;
                }
                else
                {
                    rawIpValue = Sitecore.Web.WebUtil.ExecuteWebPage(IpUrl);
                }
            }
            else
            {
                rawIpValue = Ip;
            }

            IPAddress address = IPAddress.Parse(rawIpValue);

            Tracker.CurrentVisit.GeoIp = Tracker.Visitor.DataContext.GetGeoIp(address.GetAddressBytes());
        }
コード例 #12
0
        public void Process(StartTrackingArgs args)
        {
            if (Tracker.CurrentVisit == null
              || Tracker.CurrentVisit.GeoIp == null
              || Tracker.CurrentVisit.Ip == null)
            {
                return;
            }

            string ip = new IPAddress(Tracker.CurrentVisit.GeoIp.Ip).ToString();

            if (ip != "0.0.0.0" && ip != "127.0.0.1")
            {
                return;
            }

            //string html = Sitecore.Web.WebUtil.ExecuteWebPage(
            //  "http://www.whatismyip.com/automation/n09230945.asp");
            //IPAddress address = IPAddress.Parse(html);
            IPAddress address = IPAddress.Parse(Settings.GetSetting("Debug.IPAddress","xxx.xxx.xxx.xxx"));
            Tracker.CurrentVisit.GeoIp =
              Tracker.Visitor.DataContext.GetGeoIp(address.GetAddressBytes());
        }
コード例 #13
0
        public void Process(StartTrackingArgs args)
        {
            Assert.IsNotNull((object)Tracker.Current, "Tracker.Current is not initialized");
            Assert.IsNotNull((object)Tracker.Current.Session, "Tracker.Current.Session is not initialized");
            if (Tracker.Current.Session.Interaction == null)
            {
                return;
            }

            // Since the source IP address to localhost is 127.0.0.1, we will not get back any geo ip information.
            // We are switching the address of our visit to something that will resolve and give us something back.
            if (Tracker.Current.Session.Interaction.Ip[0] == 127 && !Tracker.Current.Session.Interaction.HasGeoIpData)
            {
                //todo: add some error handling
                string[] ip = Sitecore.Configuration.Settings.GetSetting("LaunchSitecore.GeoIpSpoofForLocalhost.DefaultIPAddress").Split('.');
                if (ip.Length == 4)
                {
                    Tracker.Current.Session.Interaction.Ip[0] = Convert.ToByte(ip[0]);
                    Tracker.Current.Session.Interaction.Ip[1] = Convert.ToByte(ip[1]);
                    Tracker.Current.Session.Interaction.Ip[2] = Convert.ToByte(ip[2]);
                    Tracker.Current.Session.Interaction.Ip[3] = Convert.ToByte(ip[3]);
                }
            }
        }
コード例 #14
0
        public void Process(StartTrackingArgs args)
        {
            if (Tracker.CurrentVisit == null ||
                Tracker.CurrentVisit.GeoIp == null ||
                Tracker.CurrentVisit.Ip == null)
            {
                return;
            }

            string ip = new IPAddress(
                Tracker.CurrentVisit.GeoIp.Ip).ToString();

            if (ip != "0.0.0.0" && ip != "127.0.0.1")
            {
                return;
            }

            string html = Sitecore.Web.WebUtil.ExecuteWebPage(
                "http://www.whatismyip.com/automation/n09230945.asp");
            IPAddress address = IPAddress.Parse(html);

            Tracker.CurrentVisit.GeoIp =
                Tracker.Visitor.DataContext.GetGeoIp(address.GetAddressBytes());
        }
コード例 #15
0
        /// <summary>
        /// Process the pipeline step
        /// </summary>
        /// <param name="args"></param>
        public void Process(StartTrackingArgs args)
        {
            // bail out if null
            if (Tracker.CurrentVisit == null || Tracker.CurrentVisit.Ip == null)
            {
                return;
            }

            // get current raw IP
            //string ip = new IPAddress(Tracker.CurrentVisit.Ip).ToString();
            //Assert.IsNotNullOrEmpty(ip, "Tracker.CurrentVisit.Ip");

            //// default BadIps if not set
            //if (string.IsNullOrEmpty(BadIps))
            //{
            //    BadIps = "0.0.0.0|127.0.0.1";
            //}

            //// if the currently tracked IP is not in the list of
            //// bad IPs, don't bother processing the IP override
            //if (!BadIps.Split('|').Contains(ip))
            //{
            //    return;
            //}


            string rawIpValue = "";

            IpUrl = this.WanIpLookupOn;
            if (string.IsNullOrEmpty(IpUrl))
            {
                // no mock IP or WAN IP lookup URL
                return;
            }
            else
            {
                // fetch WAN IP via IP lookup URL
                rawIpValue = Sitecore.Web.WebUtil.ExecuteWebPage(IpUrl);
                Assert.IsNotNullOrEmpty(rawIpValue, "WAN IP lookup from <IpUrl>");
            }


            //if (string.IsNullOrEmpty(MockIp))
            //{

            //}
            //else
            //{
            //    // mock IP is configured so use it
            //    rawIpValue = MockIp;
            //    Assert.IsNotNullOrEmpty(rawIpValue, "value of <MockIp>");
            //}

            // sanitize raw IP value
            rawIpValue = rawIpValue.ToLowerInvariant().Replace("\n", "").Replace("\r", "");

            // convert IP and set to current visit
            IPAddress address = IPAddress.Parse(rawIpValue);

            Tracker.CurrentVisit.GeoIp = Tracker.Visitor.DataContext.GetGeoIp(address.GetAddressBytes());
        }