A Google Analytics event for tracking purposes.
コード例 #1
0
        public void BuildRequest_From_Google_Event()
        {
            GoogleEvent googleEvent = new GoogleEvent("mydomain.com","My Category","My Action", "My Label", 100);
            TrackingRequest actual = new RequestFactory().BuildRequest(googleEvent);

            Assert.AreEqual(actual.TrackingEvent, googleEvent);
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="eventAction"></param>
        /// <param name="eventValue"></param>
        /// <returns>Whether user opted in to analytics or not</returns>
        public static bool FireEvent(string eventAction, int? eventValue = 0)
        {
            if (OptedIn == false)
                return false;

            Logger.Info("Fired event: {0} {1}", eventAction, eventValue);

            if (Properties.Settings.Default.UserGUID == Guid.Empty)
            {
                Properties.Settings.Default.UserGUID = Guid.NewGuid();
                Properties.Settings.Default.Save();
            }

            string guidValue = Properties.Settings.Default.UserGUID.ToString();

            var googleEvent = new GoogleEvent("highlighthunter.com",
                "PC " + ConfigurationSettings.AppProductVersion,
                eventAction,
                guidValue,
                eventValue);

            lock (locker)
            {
                AnalyticsEventQueue.Enqueue(googleEvent);

                if (_isWorking == false)
                {
                    _isWorking = true;
                    RunWorker();
                }

            }

            return true;
        }
コード例 #3
0
ファイル: Analytics.cs プロジェクト: NullSoldier/Launchpad
        private void ReportEvent(string category, string action,
			string label=null, int? value=null)
        {
            var googleEvent = new GoogleEvent (DOMAIN, category,
                action, label, value);
            var request = factory.BuildRequest (googleEvent);
            GoogleTracking.FireTrackingEvent (request);
        }
コード例 #4
0
        /// <summary>
        /// Builds the tracking request from a Google Event.
        /// </summary>
        /// <param name="googleEvent">The google event.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public TrackingRequest BuildRequest(GaDotNet.Common.Data.GoogleEvent googleEvent, HttpContext context)
        {
            var r = BuildRequest(googleEvent);

            r.RequestedByIpAddress = context.Request.UserHostAddress;

            return(r);
        }
コード例 #5
0
ファイル: RequestFactory.cs プロジェクト: jlippold/Ga.net
		/// <summary>
		/// Builds the tracking request from a Google Event.
		/// </summary>
		/// <param name="googleEvent">The google event.</param>
		/// <returns></returns>
		public TrackingRequest BuildRequest (GoogleEvent googleEvent)
		{
			return new TrackingRequest {
				TrackingEvent = googleEvent,
				PageDomain = googleEvent.DomainName,
				AnalyticsAccountCode = googleAnalyticsCode
			};
		}
コード例 #6
0
        /// <summary>
        /// Builds the tracking request from a Google Event.
        /// </summary>
        /// <param name="googleEvent">The google event.</param>
        /// <returns></returns>
        public TrackingRequest BuildRequest(GaDotNet.Common.Data.GoogleEvent googleEvent)
        {
            var r = new TrackingRequest();

            r.AnalyticsAccountCode = ConfigurationSettings.GoogleAccountCode;
            r.TrackingEvent        = googleEvent;

            return(r);
        }
コード例 #7
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            GoogleEvent googleEvent = new GoogleEvent(txtDomain.Text,"Demo","Demo Testing","Demo Event - "+DateTime.Now.ToString("HH:mm:ss"),100);

            TrackingRequest request = new RequestFactory().BuildRequest(googleEvent, HttpContext.Current);

            GoogleTracking.FireTrackingEvent(request);

            litResult.Text = "Done!";
        }
コード例 #8
0
ファイル: GoogleAnalytics.cs プロジェクト: artgo/CefSharp
        public void Notify(string action, string label, int? value)
        {
            try
            {
                var googleEvent = new GoogleEvent(Constants.BaseAnalyticsDomainName, Constants.GaCategory, action, label, value);

                _log.Debug("Building event " + googleEvent);
                var request = _requestFactory.BuildRequest(googleEvent);

                _log.Debug("Firing event " + googleEvent);
                GoogleTracking.FireTrackingEvent(request);
                _log.Debug("Event " + googleEvent + " Fired");
            }
            catch (Exception e)
            {
                _log.ErrorException("Error while trying to perform analytics event", e);
            }
        }
コード例 #9
0
 public void GoogleEventConstructorTest()
 {
     string domainName = "mydomain.com";
     string category = "category";
     string action = "action";
     string label = "label";
     int value = 1;
     GoogleEvent target = new GoogleEvent(domainName, category, action, label, value);
     try
     {
         target.Validate();
     }
     catch(ArgumentException e)
     {
         Assert.Fail(e.Message);
     }
     Assert.IsTrue(true);
 }
コード例 #10
0
        protected void btnEventSubmit_Click(object sender, EventArgs e)
        {
            int eventValue;

            bool found = int.TryParse(txtEventValue.Text, out eventValue);

            GoogleEvent eventToTrack = new GoogleEvent(txtEventDomain.Text,
                txtEventCategory.Text,
                txtEventAction.Text,
                txtEventLabel.Text,
                (found ? eventValue : (int?)null));

            TrackingRequest request = new RequestFactory().BuildRequest(eventToTrack, HttpContext.Current);

            GoogleTracking.FireTrackingEvent(request);

            divAction.InnerText = "Event successfully tracked";
            divAction.Visible = true;
        }
コード例 #11
0
ファイル: Default.aspx.cs プロジェクト: jlippold/Ga.net
		protected void btnEventSubmit_Click (object sender, EventArgs e)
		{
			int parsed;
			bool found = int.TryParse(txtEventValue.Text, out parsed);
			int? eventValue = found ? parsed : (int?)null;

			GoogleEvent eventToTrack = new GoogleEvent (
				txtEventDomain.Text,
				txtEventCategory.Text,
				txtEventAction.Text,
				txtEventLabel.Text,
				eventValue);

			TrackingRequest request = new RequestFactory (ConfigurationSettings.GoogleAccountCode)
				.BuildRequest (eventToTrack);
			GoogleTracking.FireTrackingEvent(request);

			divAction.InnerText = "Event successfully tracked";
			divAction.Visible = true;
		}
コード例 #12
0
 private void SendGoogleAnalyticsEvent(string category, string action, string label, int? value)
 {
     try
     {
         if (m_sendAnalytics)
         {
             GoogleEvent googleEvent = new GoogleEvent("www.sipsorcery.com",
                 category,
                 action,
                 label,
                 value);
             TrackingRequest request = new RequestFactory().BuildRequest(googleEvent);
             ThreadPool.QueueUserWorkItem(delegate
             {
                 try
                 {
                     GoogleTracking.FireTrackingEvent(request);
                 }
                 catch { }
             });
         }
     }
     catch (Exception excp)
     {
         logger.Error("Exception SendGoogleAnalyticsEvent. " + excp.Message);
     }
 }
コード例 #13
0
        /*
        /// <summary>
        /// Builds the request.
        /// </summary>
        /// <param name="pageView">The page view.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public TrackingRequest BuildRequest(GooglePageView pageView, HttpContext context)
        {
            var r = BuildRequest(pageView);

            // add users IP address
            r.RequestedByIpAddress = context.Request.UserHostAddress;

            return r;
        }
        */
        /// <summary>
        /// Builds the tracking request from a Google Event.
        /// </summary>
        /// <param name="googleEvent">The google event.</param>
        /// <returns></returns>
        internal static TrackingRequest BuildRequest(GoogleEvent googleEvent)
        {
            var r = new TrackingRequest
                        {
                            AnalyticsAccountCode = ConfigurationSettings.GoogleAccountCode,
                            TrackingEvent = googleEvent
                        };

            return r;
        }
コード例 #14
0
ファイル: Logger.cs プロジェクト: sumitc91/M2E-2.0
 public void AsyncTrackGoogleEvents(string category, string action, string label)
 {
     var googleEvent = new GoogleEvent("MadeToEarn.com", category, action, label, 1);
     var requestEvent = new RequestFactory().BuildRequest(googleEvent);
     GoogleTracking.FireTrackingEvent(requestEvent);
 }
コード例 #15
0
        /// <summary>
        /// Track the download event
        /// </summary>
        /// <param name="path"></param>
        /// <param name="context"></param>
        /// <param name="bytes"></param>
        private static void TrackDownloadEvent(string path, HttpContextWrapper context, long bytes)
        {
            ConfigurationManager.AppSettings["GoogleAnalyticsAccountCode"] = SettingsHelper.GetGoogleAnalyticsProfile();

            var code = GaDotNet.Common.Data.ConfigurationSettings.GoogleAccountCode;

            string referrer = "NoReferrer";
            if (context.Request != null && context.Request.UrlReferrer != null)
            {
                referrer = context.Request.UrlReferrer.Host;
            }

            int kiloBytes = (int)(bytes / 1024);

            GoogleEvent googleEvent = new GoogleEvent("http://localhost.local",
                "Download",
                referrer,
                path,
                kiloBytes);

            var app = (HttpApplication)context.GetService(typeof(HttpApplication));

            TrackingRequest request =
                new RequestFactory().BuildRequest(googleEvent, app.Context);

            GoogleTracking.FireTrackingEvent(request);
        }