ts0

ts0

too simplistic

Google Analytics ASP.Net Web Control

Update 2007-11-09: I've set this up as a Google Code project, there'll be more features to come.

Google Analytics is an amazingly powerful tool, we don't build a site without it these days. In its simplest form it's not much more than a fancy looking version of your usual web server stats. When used properly though it does so much more than show you how many hits you've had, it will tell you how hard your site is working to make you money. It will show you exactly where your online marketing spend is going.

A lot of the really good stuff means fiddling around with JavaScript and some stuff isn't even in the API, like setting a campaign source from the server (without using the querystring)

So here is a handy a little web control that makes it all much easier. GAControl.zip

How to use it

Place an instance of the control in your head tag, this can be on a master page. Set the account Id property, you'll find it in the tracker code.

In the master page code file you can make it a public property.

You can then use it from any control or page to do things like add page hits for goal tracking.

Set a campaign source

Add other domains to be tracked in the same account. All links and forms going to that domain will pass the cookie across, so long as the other site is tracking with the same GA account the user session will carry across.

You can also save the details of e-commerce transactions for accurate ROI reporting.

And a few other things! Give it a go and let me know what you think.

Labels: , ,

5 Comments - Post a comment

Blogger pj

Hi - I really love this control - makes implimenting ga very neat and easy. Does it work with htpp / https sites however? I am getting "Security Error - Domain Mismatch - you have attemped to establish a connection..." message when I move from http to the secure https signup pages.

Anonymous Thom Shannon

Hi PJ, glad you like. I don't know of any reason why that would happen. Have you got a link where I can see the error? Or what is the rest of the error message, and have you checked that the SSL url is correct? If the SSL domain is the same as the site then you don't need to do anything, it should just work, if it's a different domain then you'll need to use the "AddAlternativeURL" feature

Blogger pj

Thom - I found your code on google in the end. I think the google-analytics ssl urchin source url changes to ssl.google-analytics.com - anyway i used Analytics.UrchinSource = "https://ssl.google-analytics.com/urchin.js " and that sorted it out.

Thanks for posting this project - it has proved very useful to me.

Blogger zuppaman

Is the source available for this controle ?

thx

Blogger zuppaman

Oeps forget previous comment.
Found the source :)