I’ve been using Visual Studio 2005 for almost 2½ years since the beta 1 release. In all that time, I’ve used Firefox and Firebug for all JavaScript debugging. I’ve tried setting breakpoints in JavaScript in Visual Studio before, but I never got it working so I left it for Firebug. Then the other day, our new developer at Traceworks told me that Visual Studio could be used for debugging and that it is possible to set breakpoints in the JavaScript files.

This of course illustrates that I’m slow – 2½ years slow to be exact. For those of you, who are as slow as me, keep reading and I’ll tell you how to debug JavaScripts in Visual Studio.

Set up Internet Explorer

Internet Explorer has disabled the possibility to debug scripts by default, so the first thing to do is to enable it. In the top menu, go to Tools -> Internet Options -> Advanced. Here you need to remove the checkboxes in Disable script debugging. This is needed for Internet Explorer to tell Visual Studio about the JavaScript running in the browser.

Start debugging

In included .js files you are now able to set break points as you normally would in C# or VB.NET. The execution stops at the break point and you are able to see the values of the variables and to move forward by hitting F10 and F11 like normal. The experience is exactly the same as debugging C# code.

For inline JavaScript you cannot set break points, but Microsoft did provide us with an alternative. If you add the word debugging wherever you want in the script code, the execution will stop at the word and you can debug exactly the same way as setting a break point.

For this to work, you must run Visual Studio in debug mode. That’s it, extremely powerful and easy to do. The only thing I don’t like about this is that I didn’t know about it before now. C’est la vie.

Typically, a website has one or more conversion points. A conversion is when a website visitor takes a desired action, such as a sale or downloads a file. The conversions are a way to measure the success of your website.

Examples of conversion points
  • Web shop sale
  • Signing up for a newsletter
  • Downloading a file
  • Writing a comment on a blog post
  • Sending a mail through a contact form

Pseudo metrics

If a website has no defined conversion points or no measurement tool to track the conversions, how will you know if the website is a success? You don’t. The number of visitors or page views cannot determine the success of a website, because they don’t tell you anything about the quality of the visit. They are a pseudo metric that is very fun to watch, but won’t tell you much about the success.

If a visitor searches for “orange” in a search engine and ends up on your site about the Orange Revolution in Ukraine, then the visitor quickly leaves your site again because he/she was looking for the fruit. That is not a successful visit but it did generate a page view. Do you get my point?

Look for patterns

It is not enough to know how many times people have downloaded a certain file or how many comments have been posted on your blog. The real value comes when you can follow the progress on a daily basis. If you suddenly see an increase in comments written from one day to another, you would want to know why because then you will be able to recreate it to generate even more conversions.

After a while you might start to see certain patterns that lead to increased amounts of conversions. For a blog owner, it could be certain topics or writing styles of the posts that end up generating more conversions than the other posts. Then you can adjust a few things and try to reproduce the effect in the future.

The rule of thumb

The rule of thumb on conversion is that a visitor should be able to create a conversion with the least possible clicks. In other words, make it very easy to convert. This could involve changing the navigation or to let the visitor supply only few information in a contact form so they don’t get scared away when you ask them to provide their age and gender etc. if you don’t use that information anyway. You can read more on how to improve your conversion rate here.

Get started

This is pretty basic stuff, but you need a tool that can measure these things. Otherwise you are left in the dark. You can use Google Analytics that can be used to track simple conversions such as blog post comments or Headlight for a more professional full featured analysis.

All the tools use a little piece of JavaScript to include to your web page that will execute when a visitor converts. It then sends the information back to a server elsewhere. Much like the simple visitor tracking scripts most of us use already. It’s harmless and very powerful.