The TrackingRequest factory - this helps you build your request with whatever data
        protected void Button1_Click(object sender, EventArgs e)
        {
            GoogleTransaction trans = new GoogleTransaction();

            trans.Affiliation = "Affiliated to X";
            trans.City = "Sydney";
            trans.Country = "Australia";
            trans.OrderID = "1";
            trans.ProductName = String.Format("Demo: Example Product - {0} ", DateTime.Now.ToString("HH:mm:ss"));
            trans.ProductSku = "DEMOSKU1234";
            trans.ProductVariant = "Red";
            trans.Quantity = 2;
            trans.ShippingCost = (decimal)12.50;
            trans.State = "NSW";
            trans.TaxCost = (decimal) 1.00;
            trans.TotalCost = 10;
            trans.UnitPrice = 5;

            TrackingRequest request = new RequestFactory().BuildRequest(trans);

            request.RequestedByIpAddress = Request.UserHostAddress;

            GoogleTracking.FireTrackingEvent(request);

            litResult.Text = "Done!";
        }
        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);
        }
Beispiel #3
0
		/// <summary>
		/// Tracks the page view and streams a GIF image.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <param name="pageView">The page view.</param>
		/// <param name="analyticsCode">Analytics code in the form UA-XXXXXX-X</param>
		public static void TrackPageViewWithImage (HttpContext context, GooglePageView pageView, string analyticsCode)
		{
			TrackingRequest request = new RequestFactory (analyticsCode)
				.BuildRequest(pageView);

			FireTrackingEvent(request);
			ShowTrackingImage(context);
		}
        public void BuildRequest_From_Google_Transaction()
        {
            GoogleTransaction googleTransaction = new GoogleTransaction();
            googleTransaction.Affiliation = "Affiliation";

            TrackingRequest actual = new RequestFactory().BuildRequest(googleTransaction);

            Assert.AreEqual(actual.TrackingTransaction, googleTransaction);
        }
        public void BuildRequest_From_Google_PageView()
        {
            GooglePageView pageView = new GooglePageView("My Page Title","mydomain.com","/test.aspx");
            TrackingRequest actual = new RequestFactory().BuildRequest(pageView);

            Assert.AreEqual(actual.PageDomain, "mydomain.com");
            Assert.AreEqual(actual.PageUrl, "/test.aspx");
            Assert.AreEqual(actual.PageTitle, "My Page Title");
        }
Beispiel #6
0
		/// <summary>
		/// Tracks the page view and streams a GIF image.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <param name="pageView">The page view.</param>
		public static void TrackPageViewWithImage(HttpContext context, GooglePageView pageView)
		{
			//build request
			TrackingRequest request = new RequestFactory().BuildRequest(pageView);

			FireTrackingEvent(request);
			//context.Response.Write(request.TrackingGifURL);
			ShowTrackingImage(context);
		}
        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!";
        }
Beispiel #8
0
		protected void btnPageSubmit_Click(object sender, EventArgs e)
		{
			GooglePageView pageView = new GooglePageView(txtPageTitle.Text,
				txtPageDomainName.Text,
				txtPageURL.Text);
			TrackingRequest request = new RequestFactory().BuildRequest(pageView);
			GoogleTracking.FireTrackingEvent(request);

			divAction.InnerText = "Page view successfully tracked";
			divAction.Visible = true;
		}
        protected void Button1_Click(object sender, EventArgs e)
        {
            string pageURL = String.Format("/demo-page-view-{0}.aspx", DateTime.Now.ToString("HH-mm"));

            GooglePageView pageView = new GooglePageView("Demo Page View",txtDomainName.Text, pageURL);

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

            GoogleTracking.FireTrackingEvent(request);

            litResult.Text = "Done!";
        }
 public static void TrackStartup()
 {
     try
       {
     GooglePageView pageView = new GooglePageView("youtube.fm",
                            "youtube.fm",
                            "/default.html");
     TrackingRequest request = new RequestFactory().BuildRequest(pageView);
     request.AnalyticsAccountCode = "UA-29014752-1";
     GoogleTracking.FireTrackingEvent(request);
       }
       catch (Exception exception)
       {
     Log.Error(exception);
       }
 }
Beispiel #11
0
		protected void btnPageSubmit_Click(object sender, EventArgs e)
		{
			GooglePageView pageView = new GooglePageView (
				txtPageTitle.Text,
				txtPageDomainName.Text,
				txtPageURL.Text,null);

			TrackingRequest request = new RequestFactory (AccountID.value)
				.BuildRequest (pageView);

            request.SetCustomVariable(1, new GoogleCustomVariable(txtCVKey1.Text, txtCVValue1.Text));

			GoogleTracking.FireTrackingEvent(request);

			divAction.InnerText = "Page view successfully tracked";
			divAction.Visible = true;
		}
Beispiel #12
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;
        }
Beispiel #13
0
		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;
		}
 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);
     }
 }
        public void BuildRequest_From_HttpContext()
        {
            //build fake context with fake request
            string queryString = "pagetitle=My%20Page%20Title&domain=mydomain.com&url=/test.aspx";
            HttpRequest request = new HttpRequest("/tracker.asmx", "http://localhost/tracker.asmx", queryString);
            StringWriter sw = new StringWriter();
            HttpResponse response = new HttpResponse(sw);
            HttpContext context = new HttpContext(request, response);

            TrackingRequest actual = new RequestFactory().BuildRequest(context);

            Assert.AreEqual(actual.PageDomain, "mydomain.com");
            Assert.AreEqual(actual.PageUrl, "/test.aspx");
            Assert.AreEqual(actual.PageTitle, "My Page Title");
        }
Beispiel #16
0
 public Analytics(Version version)
 {
     this.version = version;
     this.factory = new RequestFactory (ACCOUNT_CODE);
 }
Beispiel #17
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);
 }
        /// <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);
        }