Google Analytics event tracking in native code – now in GaDotNet 1.2

comments

So last week i released my new open source project GaDotNet, which allows you to track page views, events and soon to be supported, transactions, in your .net applications natively. I’ve had so much awesome feedback from the .net community, and have been busily adding features. Today i release the next version that supports events.

GaDoNet release

So being the open source admin n00b i am, i am still yet to finalise documentation and a github repo. If anyone is interested to help me get this setup, admin, or help with code – please send me an email.

Download the new release here.

New features in version 1.2

  • Added Event tracking support
  • Added the IP address parameter (thanks Meixger)
  • Added some extra overloads to the request factory
  • Added testing (naughty naughty)
  • Some general house cleaning

New event tracking API usage

The following code allows you to add an event to your Google Analytics account. You need to be aware that there is a limitation of 500 events per session put in place by Google as per this page, however as i currently haven’t implemented session support yet (the ability to track multiple page views or events under on visitor session) i don’t think this will apply. I have not tested this though, so it is an unknown.

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

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

GoogleTracking.FireTrackingEvent(request);

What’s next?

So I'm off to keep working on the next release. The things I'm planning on adding to the next release:

  • Transaction support
  • Better API Paths (feedback would be appreciated)

Things that will come later:

  • Session support
  • Bulk event, page or transaction additions (adding lists of them all at once)
  • A-synchronous support and Google Event, Page View or Transaction queue