This project is read-only.

GaDotNet is an open source library designed to make it easy to log page views, events and transactions, through code, without using JavaScript or even needing to have a browser.

  1. Built in tracking image handler
  2. API usage
  3. Single page view usage
  4. Single page view with image usage
  5. Event tracking
  6. Transaction tracking
  7. Setup


As this project is still in beta, i am only going to support page views for this release, but events and transactions are coming very soon. Additionally, it is lacking any testing, so this will come very soon too.

Potential scenarios where this library can come in handy:

  • When you want to log page views for things that normally' can’t – like web service calls, win forms application usage etc.
  • When you replace page views with Ajax calls, but still want to log the Ajax action as a second page view
  • If you want to use Google analytics to log non-website information, such as offline transactions, product catalogue statistics or store purchases.

Built in tracking image handler

If you are looking to track your FaceBook fan pages, or any other place you want to track a page view but only have the ability to link an image, but not insert the Google Analytics JavaScript.

<img src="/tracker.asmx?" />

Easy to use, simple API

To log a page view is very simple

Simple page view usage:

If you simply want to log a page view, create a page view object and track it.

GooglePageView pageView = new GooglePageView("My page title",
TrackingRequest request = new RequestFactory().BuildRequest(pageView);



Page view tracking with image usage (log with GA and stream /spacer.gif)

If you want to track a page view and then stream an spacer gif.

GooglePageView pageView = new GooglePageView("My page title",
GoogleTracking.TrackPageViewWithImage(HttpContext.Current, pageView);

Event tracking

Logging events is just as easy

int? eventValue = 100;
GoogleEvent googleEvent = new GoogleEvent("",
"Event Category",
"Event Action",
"Event Label",

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


Transaction tracking

For transactions

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;



Simply download the library, reference the DLL GaDotNet.Common in your application, set your Google Analytics Account code in the app settings of your web.config or app.config and you’re done.


<!-- Google Analytics Account code (in format UA-XXXXXX-X) -->
<add key="GoogleAnalyticsAccountCode" value="UA-599999-9"/>


Last edited Feb 17, 2011 at 10:22 PM by dougrathbone, version 2


No comments yet.