Release of Google Analytics Dot Net

comments

So today is the day that a little side project I've been working on sees the days of light. GoogleAnalyticsDotNet allows you to log a page view to Google Analytics from code behind of a website or from within a web service or win forms project without needing to use the Google JavaScript code, or even use web browser at all.

image A few months ago i had an issue where i needed to track page views on a Facebook fan page for a client. The problem is, that Google Analytics uses a remotely called JavaScript file, and there is often times where you don’t want to include a JavaScript file on a page – this is definitely the case when using a remote site like FaceBook, MySpace or even a simple web directory. The Google Analytics JavaScript itself simply builds a URL to a 1x1 transparent GIF that then gets called from Google Analytics by your web browser.

Some PHP folk have solved this issue by creating a script that takes your Google Analytics details, builds the URL for the GIF and then sends an HTTP request to Google for the file. The problem with this is, search high and low, i couldn’t find anyone who was doing the same thing in .Net – This is what this library sets out to do: fill a void.

GoogleAnalyticsDotNet will take your page view request and do the same thing: request a GIF download from Google, download it (inturn firing the tracking event). That is all it does, simple and effective.

Download

Download the library here

Sample usage

Using the library is dead easy – simply build a page view request, and call the tracking event class.

GooglePageView pageView = new GooglePageView("My page title",
                                "www.mydomain.com",
                                "/my-page-url.html");
TrackingRequest request = new RequestFactory().BuildRequest(pageView);
GoogleTracking.FireTrackingEvent(request);

So download it today and let me know if you find any new and exciting uses for it!

Where from here?

Currently the library only supports Page views, however shortly i will be releasing version 1.5 that will support events and transaction logging, using Google Analytics’ transaction logging support.