/// <summary>
        /// This method returns a list of all special page load function for a given channel.
        /// </summary>
        /// <param name="channelName">The name of the channel</param>
        /// <param name="language">The language of the related suite.</param>
        /// <returns>A string[] containing reporting suite.</returns>
        public static string[] GetSpecialPageLoadFunctionsForChannel(string channelName, string language)
        {
            List <string> rtnFunctions = new List <string>();

            WebAnalyticsOptions.Initialize();

            if (_webAnalyticsConfig != null)
            {
                var functions = from reportingSuite in _webAnalyticsConfig.ReportingSuites.Cast <ReportingSuiteElement>()
                                where
                                (((reportingSuite.Language == "") || (reportingSuite.Language == language)) &&
                                 (reportingSuite.EnabledForAllChannels ||
                                  //When looking for channel make it case insensitive.
                                  reportingSuite.Channels.Cast <ChannelElement>().Any(c => string.Compare(c.Name, channelName, true) == 0)))
                                select reportingSuite.SpecialPageLoadFunctions;

                rtnFunctions.AddRange(functions);
            }

            return(rtnFunctions.ToArray());
        }
        /// <summary>
        /// This method returns a channel name for a given folderpath. It also matches occurence
        /// of certain text in the url.
        /// </summary>
        /// <param name="urlFolderPath">This value contains the complete url</param>
        /// <returns>The channel name which matches the urlFolderPath.</returns>
        public static string GetChannelForUrlPath(string urlFolderPath)
        {
            try
            {
                WebAnalyticsOptions.Initialize();

                if (_webAnalyticsConfig.UrlPathChannelMappings != null)
                {
                    string url          = urlFolderPath.Substring(urlFolderPath.LastIndexOf('/') + 1).ToLower();
                    int    urlDelimiter = urlFolderPath.LastIndexOf('/');
                    string currUrlPath  = urlFolderPath;
                    while (!string.IsNullOrEmpty(currUrlPath))
                    {
                        var urlPathWithUrlChannelMappings = from urlPathChannel in urlPathChannelWithUrlMatchLookUp
                                                            where urlPathChannel.Key == currUrlPath && urlFolderPath.Contains(((UrlPathChannelElement)urlPathChannel.Value).UrlMatch)
                                                            select urlPathChannel;
                        if (urlPathWithUrlChannelMappings.Count() != 0)
                        {
                            return(((UrlPathChannelElement)urlPathWithUrlChannelMappings.FirstOrDefault().Value).ChannelName);
                        }

                        var urlPathChannelMappings = from urlPathChannel in urlPathChannelLookUp
                                                     where urlPathChannel.Key == currUrlPath
                                                     select urlPathChannel;

                        if (urlPathChannelMappings.Count() != 0)
                        {
                            return(((UrlPathChannelElement)urlPathChannelMappings.FirstOrDefault().Value).ChannelName);
                        }

                        // did not find, backtrack the url path to find the matching elements
                        urlDelimiter = currUrlPath.LastIndexOf('/');

                        if (currUrlPath == "/" && urlDelimiter == -1)
                        {
                            // shoud never come here, there should be the minumum '/' mapping in the web.config
                            currUrlPath = String.Empty;
                            continue;
                        }

                        currUrlPath = currUrlPath.Substring(0, urlDelimiter).ToLower();

                        //Reached the beginning of the url path or the request is for the home page.
                        //when this happens set the path '/' so the lookup can succeed. This
                        //is the final fall back.
                        if (string.IsNullOrEmpty(currUrlPath))
                        {
                            currUrlPath = "/";
                        }
                    }

                    // if it reaches here then, no mapping could be found.
                    log.InfoFormat("GetChannelForUrlPath(): No channel mapping exists for pretty url: {0}", urlFolderPath);
                }
                else
                {
                    log.Info("GetChannelForUrlPath(): Url to channel mapping information not present in config file.");
                }
            }
            catch (Exception ex)
            {
                log.Error("GetChannelForUrlPath(): Failed to process url to channel mapping", ex);
            }

            // Should never be executed.
            return("");
        }