July 2008 - Posts

Web Analytics with Clicky

I have tried out several of the services out there that allow you to track your statistics and analyze visitors and hits on your site.  Some are free and some of them have a small fee.  One of the ones that I have been the most impressed with has been Clicky.  This service gives you a nice dashboard that lists all kinds of information about your site in a very easy-to-read format.

clicky1

Like a lot of the other services, you simply place a small amount of javascript code in the template for your web page or blog and you can start seeing results.  They even have a very cool “Spy” feature that uses an Ajax to show you who is on your site right now and what they are looking at.

 

spy

 

vista-gadgetThey have both a free and a premium paid service.  They premium service offers you a ton of features that you don’t find in most other services.   They provide a developer API that allows you to create any kind of GUI that you might want and have it integrated into your application or site.  They also provide a lot of widgets for iGoogle, Wordpress, Vista, etc on their site.

You can also integrate this with your FeedBurner feeds to be able to track actions from users.  This gives you much more details than you find with the default statistics from Google’s FeedBurner. 

The service also allows you to track keywords, visitor actions, as well as the usual browsers, computers, and information about where visitors are from.  Giving you a list of the most popular pages on your site can allow you to optimize traffic based on what keywords that visitors are using to find your site.

Before using Clicky, I was using Google’s tracking service.   I started looking for another service when I had issues reporting on multi-day segments or when I wanted to track multiple sites.  I would often get taken to reports for a different site when I would browse reports within Google’s UI. 

I would try out their features if you are interested.  They have a free 14 day trial of their premium service that allows you to determine if you want the extra features that the free service does not include.

Brenton House

Posted by dotnetboy2003 | 1 comment(s)
Filed under:

Extension Methods with Enum Description

Since Enum names in .NET do not support certain characters like spaces, often developers will use the DescriptionAttribute to add detailed text to an Enum. 

   [Flags]
   internal enum SuperHero 
   {
      [Description("Clark Kent")]
      Superman = 1,
      [Description("Peter Parker")]
      SpiderMan = 2,
      [Description("Bruce Banner")]
      Hulk = 4,
      [Description("Tony Stark")]
      IronMan = 8,
   }

You can pull the description from the enum with code like this.  (Keep in mind that you can make this MUCH faster using DynamicMethods and caching, but that is another article…)

      private const char ENUM_SEPERATOR_CHARACTER = ',';
      public static string GetDescription(Enum value)
      {
         // Check for Enum that is marked with FlagAttribute
         var entries = value.ToString().Split(ENUM_SEPERATOR_CHARACTER);
         var description = new string[entries.Length];
         for (var i = 0; i < entries.Length; i++)
         {
            var fieldInfo = value.GetType().GetField(entries[i].Trim());
            var attributes = (DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
            description[i] = (attributes.Length > 0) ? attributes[0].Description : entries[i].Trim();
         }
         return String.Join(", ", description);
      }

Well, now with .NET 3.5 and Extension methods it only makes sense to make this a little bit easier.

      public static string Description(this Enum value)
      {
         return GetDescription(value);
      }

And now you can do the following:

         var secretIdentity = SuperHero.Superman.Description();
         var superHeroes = SuperHero.Superman | SuperHero.SpiderMan;
         var secretIdentities = superHeroes.Description();

Note that the code handles Enum marked with the FlagAttribute as well.  The output of the whole flag thing is not ideal but at least it does not break when handling those Enums.

Brenton House

Posted by dotnetboy2003 | 3 comment(s)
Filed under: ,
More Posts