public void StoreUtmInfo(UtmInfo utmInfo)
 {
     try
     {
         OpenConnection();
         _utmInfoRepository.Create(utmInfo);
     }
     finally
     {
         CloseConnection();
     }
 }
Example #2
0
        private UtmInfo GetUtmInfo()
        {
            var utmStrings = new[] { "Source", "Medium", "Term", "Content", "Campaign" };
            var hasData    = false;
            var utmInfo    = new UtmInfo();

            foreach (var s in utmStrings)
            {
                var httpCookie = Request.Cookies.Get(string.Format("utm_{0}", s.ToLower()));
                if (httpCookie != null)
                {
                    var propertyInfo = utmInfo.GetType().GetProperty(s);
                    propertyInfo.SetValue(utmInfo, httpCookie.Value);
                    hasData = true;
                }
            }

            return(hasData ? utmInfo : null);
        }
Example #3
0
        /// <summary>
        /// Captures the UTM information from the query string and returns a populated object
        /// </summary>
        /// <returns></returns>
        public static UtmInfo GetUtm()
        {
            var utm = new UtmInfo();

            try
            {
                var httpContext = System.Web.HttpContext.Current;
                if (httpContext == null || httpContext.Request == null)
                {
                    return(utm);
                }

                if (httpContext.Request.QueryString != null)
                {
                    if (httpContext.Request.QueryString["utm_campaign"] != null)
                    {
                        utm.Campaign = httpContext.Request.QueryString["utm_campaign"].ToString();
                    }
                    if (httpContext.Request.QueryString["utm_medium"] != null)
                    {
                        utm.Medium = httpContext.Request.QueryString["utm_medium"].ToString();
                    }
                    if (httpContext.Request.QueryString["utm_source"] != null)
                    {
                        utm.Source = httpContext.Request.QueryString["utm_source"].ToString();
                    }
                    if (httpContext.Request.QueryString["utm_content"] != null)
                    {
                        utm.Content = httpContext.Request.QueryString["utm_content"].ToString();
                    }
                    if (httpContext.Request.QueryString["utm_term"] != null)
                    {
                        utm.Term = httpContext.Request.QueryString["utm_term"].ToString();
                    }
                }
            }
            catch
            {
                return(utm);
            }
            return(utm);
        }
Example #4
0
 public void StoreUtmInfo(UtmInfo utmInfo)
 {
     _adminRepository.StoreUtmInfo(utmInfo);
 }