コード例 #1
0
    private static void TrackReferral(string siteName)
    {
        string referrerURL = (RequestStockHelper.GetItem("AnalyticsReferrerString") as string);

        if (!string.IsNullOrEmpty(referrerURL))
        {
            Uri referrer = new Uri(referrerURL);
            if ((referrer != null) && (CMSContext.ViewMode == ViewModeEnum.LiveSite))
            {
                if (!referrer.AbsoluteUri.StartsWithCSafe("/") && !referrer.IsLoopback && (referrer.Host.ToLowerCSafe() != URLHelper.Url.Host))
                {
                    // Check other site domains
                    SiteInfo rsi = SiteInfoProvider.GetRunningSiteInfo(referrer.Host, URLHelper.ApplicationPath);
                    if ((rsi == null) || (rsi.SiteName != siteName))
                    {
                        string path = URLHelper.RemoveQuery(referrer.AbsoluteUri);

                        // Save the referrer value
                        CMSContext.CurrentUser.URLReferrer = path;

                        // Log referral
                        string ip = HTTPHelper.UserHostAddress;
                        HitLogProvider.LogHit(HitLogProvider.URL_REFERRALS, siteName, null, path, 0);
                    }
                }
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (!StopProcessing && AnalyticsHelper.IsLoggingEnabled(CMSContext.CurrentSiteName, CMSContext.CurrentAliasPath))
        {
            // Log only for non empty statistics name
            if (!String.IsNullOrEmpty(StatisticsName))
            {
                // Log only for live site
                if (CMSContext.ViewMode == ViewModeEnum.LiveSite)
                {
                    // If once per user is set - log only once per session
                    if (OncePerUser)
                    {
                        // If already in the session - do not log
                        if (SessionHelper.GetValue("CustomStatisticsLogged_" + StatisticsName) != null)
                        {
                            return;
                        }

                        SessionHelper.SetValue("CustomStatisticsLogged_" + StatisticsName, true);
                    }

                    HitLogProvider.LogHit(StatisticsName, CMSContext.CurrentSiteName, CMSContext.CurrentPageInfo.DocumentCulture, StatisticsObjectName, CMSContext.CurrentPageInfo.NodeID, 1, StatisticsValue);
                }
            }
        }
    }
コード例 #3
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        // Log hit only if we are on the live site and banner is not reused from previous request
        if ((currentViewMode == CMS.PortalEngine.ViewModeEnum.LiveSite) && (banner != null) && !bannerReused)
        {
            string currentSiteName = CMSContext.CurrentSiteName;

            if (AnalyticsHelper.AnalyticsEnabled(currentSiteName))
            {
                HitLogProvider.LogHit("bannerhit", currentSiteName, null, null, banner.BannerID);
            }
        }
    }
コード例 #4
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        // Log hit only if we are on the live site and banner is not reused from previous request
        if ((currentViewMode == CMS.PortalEngine.ViewModeEnum.LiveSite) && (banner != null) && !bannerReused)
        {
            string currentSiteName = SiteContext.CurrentSiteName;

            if (AnalyticsHelper.AnalyticsEnabled(currentSiteName))
            {
                if (AnalyticsHelper.JavascriptLoggingEnabled(SiteContext.CurrentSiteName))
                {
                    WebAnalyticsServiceScriptsRenderer.RegisterLogBannerHitCall(Page, banner.BannerID);
                }
                else
                {
                    HitLogProvider.LogHit("bannerhit", currentSiteName, null, null, banner.BannerID);
                }
            }
        }
    }
コード例 #5
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        // Log hit only if we are on the live site and banner is not reused from previous request
        if ((currentViewMode == CMS.PortalEngine.ViewModeEnum.LiveSite) && (banner != null) && !bannerReused)
        {
            string currentSiteName = CMSContext.CurrentSiteName;

            if (AnalyticsHelper.AnalyticsEnabled(currentSiteName))
            {
                if (AnalyticsHelper.JavascriptLoggingEnabled(CMSContext.CurrentSiteName))
                {
                    ScriptHelper.RegisterWebServiceCallFunction(Page);
                    string script = "WebServiceCall('" + URLHelper.GetAbsoluteUrl("~/CMSPages/WebAnalyticsService.asmx") + "','LogBannerHit', '{\"bannerID\":\"" + banner.BannerID + "\"}')";
                    ScriptHelper.RegisterStartupScript(Page, typeof(string), "logSearch", script, true);
                }
                else
                {
                    HitLogProvider.LogHit("bannerhit", currentSiteName, null, null, banner.BannerID);
                }
            }
        }
    }
コード例 #6
0
    /// <summary>
    /// Logs analytics and/or activity event.
    /// </summary>
    /// <param name="file">File to be sent</param>
    protected void LogEvent(CMSOutputFile file)
    {
        if (IsLiveSite && (file != null) && (file.FileNode != null) && (file.FileNode.NodeClassName.ToLower() == "cms.file"))
        {
            // Check if request is multipart request and log event if not
            GetRange(100, HttpContext.Current);  // GetRange() parses request header and sets 'IsMultipart' property
            if (!IsMultipart)
            {
                if (IsRangeRequest && (BrowserHelper.IsIE() || BrowserHelper.IsChrome()))
                {
                    return;
                }
            }
            else
            {
                return;
            }

            if (file.Attachment == null)
            {
                return;
            }

            // Log analytics hit
            if (AnalyticsHelper.IsLoggingEnabled(CurrentSiteName, String.Empty) && AnalyticsHelper.TrackFileDownloadsEnabled(CurrentSiteName) && !AnalyticsHelper.IsFileExtensionExcluded(CurrentSiteName, file.Attachment.AttachmentExtension))
            {
                HitLogProvider.LogHit(HitLogProvider.FILE_DOWNLOADS, CurrentSiteName, file.FileNode.DocumentCulture, file.FileNode.NodeAliasPath, file.FileNode.NodeID);
            }

            // Log download activity
            // Get current contact ID and check if activity logging is enabled
            int  contactId = 0;
            bool loggingActivityEnabled = LoggingActivityEnabled(file, out contactId);
            if (loggingActivityEnabled && (contactId > 0))
            {
                ActivityLogHelper.LogFileDownload(contactId, CurrentSiteName, file.FileNode.NodeID, file.FileNode.DocumentName, file.Attachment.AttachmentName, file.FileNode.DocumentCulture);
            }
        }
    }
コード例 #7
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (!StopProcessing && AnalyticsHelper.IsLoggingEnabled(SiteContext.CurrentSiteName, DocumentContext.CurrentAliasPath) &&
            Service.Resolve <IAnalyticsConsentProvider>().HasConsentForLogging())
        {
            // Log only for non empty statistics name and only for live site
            if (!String.IsNullOrEmpty(StatisticsName) && PortalContext.ViewMode.IsLiveSite())
            {
                // If once per user is set - log only once per session
                if (OncePerUser)
                {
                    // If already in the session - do not log
                    if (SessionHelper.GetValue("CustomStatisticsLogged_" + StatisticsName) != null)
                    {
                        return;
                    }

                    SessionHelper.SetValue("CustomStatisticsLogged_" + StatisticsName, true);
                }

                HitLogProvider.LogHit(StatisticsName, SiteContext.CurrentSiteName, DocumentContext.CurrentPageInfo.DocumentCulture, StatisticsObjectName, DocumentContext.CurrentPageInfo.NodeID, 1, StatisticsValue);
            }
        }
    }
コード例 #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // If analytics not enabled - no log
        if (!AnalyticsHelper.IsLoggingEnabled(CMSContext.CurrentSiteName, String.Empty))
        {
            return;
        }

        string data    = QueryHelper.GetString("data", String.Empty);
        string guid    = ValidationHelper.GetString(SessionHelper.GetValue("BrowserCapatibilities"), String.Empty);
        string urlGuid = QueryHelper.GetString("guid", String.Empty);

        // Compares GUIDs to prevent false data
        if ((String.IsNullOrEmpty(guid) || String.IsNullOrEmpty(urlGuid) || (guid != urlGuid)))
        {
            return;
        }

        if (!String.IsNullOrEmpty(data))
        {
            String   siteName    = CMSContext.CurrentSiteName;
            String   cultureCode = CultureHelper.GetPreferredCulture();
            string[] values      = data.Split(';');
            if (values.Length == 7)
            {
                // Resolution
                if (!String.IsNullOrEmpty(values[0]) && !String.IsNullOrEmpty(values[1]) &&
                    ValidationHelper.IsInteger(values[0]) && ValidationHelper.IsInteger(values[1]))
                {
                    string res = values[0] + "x" + values[1];
                    HitLogProvider.LogHit(HitLogProvider.SCREENRESOLUTION, siteName, cultureCode, res, 0);
                    CMSContext.Current.BrowserHelper.ScreenResolution = res;
                }

                // Color depth
                if (!String.IsNullOrEmpty(values[2]) && ValidationHelper.IsInteger(values[2]))
                {
                    string depth = values[2] + "-bit";
                    HitLogProvider.LogHit(HitLogProvider.SCREENCOLOR, siteName, cultureCode, depth, 0);
                    CMSContext.Current.BrowserHelper.ScreenColorDepth = depth;
                }

                // OS
                if (!String.IsNullOrEmpty(values[3]))
                {
                    string name = String.Empty;
                    switch (values[3])
                    {
                    case "0":
                        name = "Uknown OS";
                        break;

                    case "1":
                        name = "Windows";
                        break;

                    case "2":
                        name = "Mac OS";
                        break;

                    case "3":
                        name = "UNIX";
                        break;

                    case "4":
                        name = "Linux";
                        break;

                    case "5":
                        name = "Solaris";
                        break;
                    }

                    if (name != String.Empty)
                    {
                        HitLogProvider.LogHit(HitLogProvider.OPERATINGSYSTEM, siteName, cultureCode, name, 0);
                        CMSContext.Current.BrowserHelper.OperatingSystem = name;
                    }
                }

                // Silverlight
                if (!String.IsNullOrEmpty(values[4]) && ValidationHelper.IsInteger(values[4]))
                {
                    bool   hasSilverlight = (values[4] != "0");
                    string value          = hasSilverlight ? "hs" : "ns";
                    HitLogProvider.LogHit(HitLogProvider.SILVERLIGHT, siteName, cultureCode, value, 0);
                    CMSContext.Current.BrowserHelper.IsSilverlightInstalled = hasSilverlight;
                }

                // Java
                if (!String.IsNullOrEmpty(values[5]) && ValidationHelper.IsBoolean(values[5]))
                {
                    bool   hasJava = (values[5].ToLower() != "false");
                    string value   = hasJava ? "hj" : "nj";
                    HitLogProvider.LogHit(HitLogProvider.JAVA, siteName, cultureCode, value, 0);
                    CMSContext.Current.BrowserHelper.IsSilverlightInstalled = hasJava;
                }

                // Flash
                if (!String.IsNullOrEmpty(values[6]) && ValidationHelper.IsInteger(values[6]))
                {
                    bool   hasFlash = (values[6] != "0");
                    string value    = hasFlash ? "hf" : "nf";
                    HitLogProvider.LogHit(HitLogProvider.FLASH, siteName, cultureCode, value, 0);
                    CMSContext.Current.BrowserHelper.IsSilverlightInstalled = hasFlash;
                }
            }
        }
    }
コード例 #9
0
    public string LogHits(string pageGUID, string referrer)
    {
        string   siteName    = CMSContext.CurrentSiteName;
        UserInfo currentUser = CMSContext.CurrentUser;

        // Need to fake referrer and current page
        RequestStockHelper.Add("AnalyticsReferrerString", referrer);
        PageInfo currentPage = CMSContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(new Guid(pageGUID));

        if (!AnalyticsHelper.JavascriptLoggingEnabled(siteName))
        {
            throw new InvalidOperationException("logging by JS not enabled");
        }

        // ONLINE MARKETING
        {
            // Log activities
            if (ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser))
            {
                int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID();

                CMSContext.ContactID = contactId;
                if (contactId > 0)
                {
                    ModuleCommands.OnlineMarketingLogLandingPage(0);
                    ModuleCommands.OnlineMarketingLogExternalSearch(0);
                    ModuleCommands.OnlineMarketingLogPageVisit(0);
                    UpdateContactsIPandUserAgent(siteName);
                }
            }
        }

        if (AnalyticsHelper.IsLoggingEnabled(siteName, currentPage.NodeAliasPath))
        {
            // PAGE VIEW
            if (AnalyticsHelper.TrackPageViewsEnabled(siteName))
            {
                HitLogProvider.LogHit(HitLogProvider.PAGE_VIEWS, siteName, currentUser.PreferredCultureCode, currentPage.NodeAliasPath, currentPage.NodeID);
            }


            // AGGREGATED VIEW
            /// not logged by JavaScript call


            // FILE DOWNLOADS
            /// file downloads are logged via special WebPart that directly outputs specified file (and before that logs a hit), so there is no way we can log this via JS


            // BROWSER CAPABILITIES
            /// are already logged by JavaScript via WebPart AnalayicsBrowserCapabilities


            // SEARCH CRAWLER
            /// not logged by JavaScript call


            // INVALID PAGES
            /// throw 404 and there's no need to call it via JavaScript (even if RSS gets 404, we should know about it)


            // URL REFFERALS
            /// RSS readers and crawlers might set custom referral, so this is needed
            /// cannot be loopback
            /// cannot be the same host
            if (AnalyticsHelper.TrackReferralsEnabled(siteName))
            {
                TrackReferral(siteName);
            }

            // ON-SITE SEARCH KEYWORDS
            /// separate method


            // BANNER HITS
            /// separate method


            // BANNER CLICKS


            // VISITOR
            // BROWSER TYPE
            // MOBILE DEVICES
            // BROWSER TYPE
            // COUNTRIES
            /// Cookies VisitorStatus, VisitStatus (a obsolete CurrentVisitStatus)
            /// IP
            /// method uses AnalyticsHelper.GetContextStatus and AnalyticsHelper.SetContextStatus and also logs all mobile devices
            AnalyticsMethods.LogVisitor(siteName);


            // REFERRING SITE
            // ALL TRAFFIC SOURCES (REFERRINGSITE + "_local") (REFERRINGSITE + "_direct") (REFERRINGSITE + "_search") (REFERRINGSITE + "_referring")
            // SEARCH KEYWORDS
            // LANDING PAGE
            // EXIT PAGE
            // TIME ON PAGE
            AnalyticsMethods.LogAnalytics(SessionHelper.GetSessionID(), currentPage, siteName);
        }

        return("ok");
    }
コード例 #10
0
 public string LogBannerHit(string bannerID)
 {
     HitLogProvider.LogHit("bannerhit", CMSContext.CurrentSiteName, null, null, ValidationHelper.GetInteger(bannerID, 0));
     return("ok");
 }