The spying of users activity is good for you businessï»¿ !
Web analytics are an important part for a website; it allows the site owner to understand what users are looking for and to enhance his site in order to grab more users.
Web Analytics systems.
One of the most popular system is google analytics, if you have a google account, you can use this system for your sites.
You just have to create an entry for your website on www.google.com/analytics.
It generates for you a piece of code with a specific ID that you have to paste just before the closing head tag of each of the pages you want to monitor.
An alternative is Piwik, which is open source.
This web application has to be installed on a web server (with php/mysql).
With ASP.NET Webforms.
In ASP.NET Webform you can copy this tracking code on your main Master page and itâ€™s included in all pages using this master page.
But it requires modifying the page and redeploying the web site.
You can also use the Global.asax to add code to each page which is generated. It also requires redeployment.
Another alternative are the httpmodules.
It allows you to add functionalities to a website with just copying a dll file in the bin directory of your application and reference it in your main web.config file.
Itâ€™s the solution I choose in order to add analytics functionality to a website already running.
SAHM for Simple Analytics HttpModule.
My first implementation added only google tracking code, but I added piwik just in case and because I was testing this system.
I made it public, so you can download it from codeplex at the address : http://sahm.codeplex.com/
To use it:
1.) Copy the SAHM.dll file in the bin folder of your application
2.) Edit your Web.Config application file.
2.1) Locate <configSections> and add
<sectionGroup name="SAHM"> <section name="google" type="SAHM.GoogleConfig, SAHM" allowLocation="true" allowDefinition="Everywhere"/> <section name="piwik" type="SAHM.PiwikConfig, SAHM" allowLocation="true" allowDefinition="Everywhere"/> </sectionGroup>
2.1) Add a SAHM section
<SAHM> <google Code="UA-XXXXXX-X"/> <piwik Server="www.yourpiwikserver/" IDSite="1"/> </SAHM>
Set your identifiers.
For the piwik : be sure to set the Server value without the “http://”
2.3) Add the module in the <module>
<httpModules> <add name="SAHM" type="SAHM.AnalyticsModule, SAHM"/> </httpModules>
or if you use II7
<system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer>
2.4) Save your web.config file and test if your tracking code is in your page code.
2.5) That’s it
If you enjoy this module, please let me know!
Happy web traffic analyses.
Download link : http://sahm.codeplex.com/