示例#1
0
        public Tracker(string trackingAccount, string trackingDomain)
        {
            TrackingAccount = trackingAccount;
            TrackingDomain  = trackingDomain;

#if !WINDOWS_PHONE
            string hostname        = Dns.GetHostName();
            string osversionstring = Environment.OSVersion.VersionString;
#else
            string hostname        = "Windows Phone";
            string osversionstring = "Windows Phone";
#endif
            Hostname        = hostname;
            Language        = "en";
            UserAgent       = string.Format("Tracker/1.0 ({0}; {1}; {2})", Environment.OSVersion.Platform, Environment.OSVersion.Version, osversionstring);
            CookieContainer = new CookieContainer();

            ThrowOnErrors = false;

            InitializeUtmHid();
            InitializeCharset();
            InitializeCookieVariable();

            CustomVariables = new CustomVariable[5];

            _utmeGenerator = new UtmeGenerator(this);
        }
        private string _sessionId; // Session ID - utmhid

        #endregion Fields

        #region Constructors

        public Tracker(string trackingAccount, string trackingDomain)
        {
            TrackingAccount = trackingAccount;
            TrackingDomain = trackingDomain;

            #if !WINDOWS_PHONE
            string hostname = Dns.GetHostName();
            string osversionstring = Environment.OSVersion.VersionString;
            #else
            string hostname = "Windows Phone";
            string osversionstring = "Windows Phone";
            #endif
            Hostname = hostname;
            Language = "en";
            UserAgent = string.Format("Tracker/1.0 ({0}; {1}; {2})", Environment.OSVersion.Platform, Environment.OSVersion.Version, osversionstring);
            CookieContainer = new CookieContainer();

            ThrowOnErrors = false;

            InitializeUtmHid();
            InitializeCharset();
            InitializeCookieVariable();

            CustomVariables = new CustomVariable[5];

            _utmeGenerator = new UtmeGenerator(this);
        }
示例#3
0
        private string _cookieValue; // Cookie related variables - utmcc

        #endregion Fields

        #region Constructors

        public Tracker(string trackingAccount, string trackingDomain)
        {
            TrackingAccount = trackingAccount;
            TrackingDomain = trackingDomain;

            #if !WINDOWS_PHONE
            string hostname = Dns.GetHostName();
            string osversionstring = Environment.OSVersion.VersionString;
            #else
            string hostname = "Windows Phone";
            string osversionstring = "Windows Phone";
            #endif
            Hostname = hostname;
            Language = "en";
            UserAgent = string.Format("Tracker/2.0 ({0}; {1}; {2})", Environment.OSVersion.Platform, Environment.OSVersion.Version, osversionstring);
            CookieContainer = new CookieContainer();

            ThrowOnErrors = Debugger.IsAttached;

            CharacterSet = "UTF-8";
            InitializeCookieVariable();

            CustomVariables = new CustomVariable[5];

            _extensibleParameterGenerator = new ExtensibleParameterGenerator(this);
        }
示例#4
0
        public void SetCustomVariable(int position, string name, string value)
        {
            if (position < 1 || position > 5)
            {
                throw new ArgumentOutOfRangeException(string.Format("position {0} - {1}", position, "Must be between 1 and 5"));
            }

            CustomVariables[position - 1] = new CustomVariable(name, value);
        }
示例#5
0
        public Tracker(string trackingAccount, string trackingDomain, IAnalyticsSession analyticsSession)
        {
            TrackingAccount  = trackingAccount;
            TrackingDomain   = trackingDomain;
            AnalyticsSession = analyticsSession;

#if !WINDOWS_PHONE && !NETFX_CORE
            string hostname        = Dns.GetHostName();
            string osversionstring = Environment.OSVersion.VersionString;
            string osplatform      = Environment.OSVersion.Platform.ToString();
            string osversion       = Environment.OSVersion.Version.ToString();
#elif WINDOWS_PHONE
            string hostname        = "Windows Phone";
            string osversionstring = "Windows Phone";
            string osplatform      = "Windows Phone";
            string osversion       = Environment.OSVersion.Version.ToString();
#else
            string hostname        = "Windows";
            string osversionstring = "RT";
            string osplatform      = "Windows RT";
            string osversion       = "8";
#endif

            Hostname  = hostname;
            Language  = "en";
            UserAgent = string.Format("Tracker/1.0 ({0}; {1}; {2})", osplatform, osversion, osversionstring);

#if !WINDOWS_PHONE && !NETFX_CORE
            if (IsHttpRequestAvailable())
            {
                Hostname  = System.Web.HttpContext.Current.Request.Url.Host;
                UserAgent = System.Web.HttpContext.Current.Request.UserAgent;
                Language  = System.Web.HttpContext.Current.Request.UserLanguages != null?string.Join(";", System.Web.HttpContext.Current.Request.UserLanguages) : "";
            }
#endif

            CookieContainer = new CookieContainer();

            ThrowOnErrors = false;

            InitializeCharset();

            CustomVariables = new CustomVariable[5];

            _utmeGenerator = new UtmeGenerator(this);
        }
        public Tracker(string trackingAccount, string trackingDomain, IAnalyticsSession analyticsSession)
        {
            TrackingAccount = trackingAccount;
            TrackingDomain = trackingDomain;
            AnalyticsSession = analyticsSession;

            #if !WINDOWS_PHONE && !NETFX_CORE
            string hostname = Dns.GetHostName();
            string osversionstring = Environment.OSVersion.VersionString;
            string osplatform = Environment.OSVersion.Platform.ToString();
            string osversion = Environment.OSVersion.Version.ToString();
            #elif WINDOWS_PHONE
            string hostname = "Windows Phone";
            string osversionstring = "Windows Phone";
            string osplatform = "Windows Phone";
            string osversion = Environment.OSVersion.Version.ToString();
            #else
            string hostname = "Windows";
            string osversionstring = "RT";
            string osplatform = "Windows RT";
            string osversion = "8";
            #endif

            Hostname = hostname;
            Language = "en";
            UserAgent = string.Format("Tracker/1.0 ({0}; {1}; {2})", osplatform, osversion, osversionstring);

            #if !WINDOWS_PHONE && !NETFX_CORE
            if (IsHttpRequestAvailable())
            {
                Hostname = System.Web.HttpContext.Current.Request.Url.Host;
                UserAgent = System.Web.HttpContext.Current.Request.UserAgent;
                Language = System.Web.HttpContext.Current.Request.UserLanguages != null ? string.Join(";", System.Web.HttpContext.Current.Request.UserLanguages) : "";
            }
            #endif

            CookieContainer = new CookieContainer();

            ThrowOnErrors = false;

            InitializeCharset();

            CustomVariables = new CustomVariable[5];

            _utmeGenerator = new UtmeGenerator(this);
        }
        public Tracker(string trackingAccount, string trackingDomain, IAnalyticsSession analyticsSession)
        {
            TrackingAccount = trackingAccount;
            TrackingDomain = trackingDomain;
            AnalyticsSession = analyticsSession;

            Language = CultureInfo.CurrentCulture.ToString();
            #if !WINDOWS_PHONE
            UserAgent = string.Format("Tracker/1.0 ({0}; {1}; {2})", Environment.OSVersion.Platform, Environment.OSVersion.Version, Environment.OSVersion.VersionString);
            Hostname = Dns.GetHostName();
            #else
            Hostname = "Windows Phone";
            /* This was my first try, reconstructing the same user agent that google analytics for android sdk was sending. It didn't recognized other info that
             * OS Windows Phone.
            // Version ver = new Version(System.Reflection.Assembly.GetExecutingAssembly().FullName.Split(',')[1].Split('=')[1]);
            UserAgent = string.Format("GoogleAnalytics/1.4.2 ({0}; U; {1}; {2}; {3} Build/{4})",
                                      Environment.OSVersion.Platform.ToString(),
                                      osversionstring + " " + Environment.OSVersion.Version.ToString(),
                                      CultureInfo.CurrentCulture.ToString(), DeviceStatus.DeviceManufacturer + " " + DeviceStatus.DeviceName,
                                      Environment.OSVersion.Version.Build);
             */

            /* This is my second and working solution: we reconstruct the exact same useragent that IE9 is sending. In that way
             * Google Analytics recognize OS, Manufacturer and device model: wonderful!
             */
            string osver;
            // Windows Phone 7.5, as we usually call Mango, in reality is 7.10... So we change that string.
            if (Environment.OSVersion.Version.Major == 7 && Environment.OSVersion.Version.Minor == 10) osver = "7.5";
            else osver = string.Format("{0}.{1}", Environment.OSVersion.Version.Major,Environment.OSVersion.Version.Minor) ;

            UserAgent = string.Format("Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS {0}; Trident/5.0; IEMobile/9.0; {1}; {2})",
                                      osver, Microsoft.Phone.Info.DeviceStatus.DeviceManufacturer, Microsoft.Phone.Info.DeviceStatus.DeviceName);
            #endif
            CookieContainer = new CookieContainer();

            ThrowOnErrors = false;

            InitializeCharset();

            CustomVariables = new CustomVariable[5];

            _utmeGenerator = new UtmeGenerator(this);
        }
        public Tracker(string trackingAccount, string trackingDomain, IAnalyticsSession analyticsSession)
        {
            TrackingAccount = trackingAccount;
            TrackingDomain = trackingDomain;
            AnalyticsSession = analyticsSession;

            #if !WINDOWS_PHONE && !NETFX_CORE && !UNITY3D
            string hostname = Dns.GetHostName();
            string osversionstring = Environment.OSVersion.VersionString;
            string osplatform = Environment.OSVersion.Platform.ToString();
            string osversion = Environment.OSVersion.Version.ToString();
            #elif WINDOWS_PHONE
            string hostname = "Windows Phone";
            string osversionstring = "Windows Phone";
            string osplatform = "Windows Phone";
            string osversion = Environment.OSVersion.Version.ToString();
            #else
            string hostname = "Windows";
            string osversionstring = "RT";
            string osplatform = "Windows RT";
            string osversion = "8";
            #endif

            Hostname = hostname;
            Language = "en";
            UserAgent = string.Format("Tracker/1.0 ({0}; {1}; {2})", osplatform, osversion, osversionstring);
            CookieContainer = new CookieContainer();

            ThrowOnErrors = false;

            InitializeCharset();

            CustomVariables = new CustomVariable[5];

            _utmeGenerator = new UtmeGenerator(this);
        }
        public void SetCustomVariable(int position, string name, string value)
        {
            if (position < 1 || position > 5)
                throw new ArgumentOutOfRangeException(string.Format("position {0} - {1}", position, "Must be between 1 and 5"));

            CustomVariables[position - 1] = new CustomVariable(name, value);
        }