When I first started creating and managing websites, I discovered the immediate need to track the number of visitors. But I needed more than just a simple counter. I wanted to know their browser settings to properly design a cross-browser friendly website and where in the world visitors are from. I’ve tried half a dozen sites and found StatCounter.com as the best free service.
StatCounter.com’s service is entirely hosted on their homepage, so there is no program installation which makes setting up as simple as pasting a script on each page requiring tracking. They offer much the same as similar sites, but take it a step further. My favorite aspect is the option of an invisible tracker. As a trade-off on other stat tracking sites, the tracking script automatically places a small button linking back to their site. I find this often does not flow well with design and/or page load time. Below are some of the many options available as a free account.
- Summary
- Popular Pages
- Entry Pages
- Exit Pages
- Came From
- Keyword Analysis
- Recent Keyword Activity
- Recent Came From
- Search Engine Wars
- Visitor Paths
- Visit Length
- Returning Visits
- Recent Pageload Activity
- Recent Visitor Activity
- Recent Visitor Map
- Country/State/City/ISP
- Browser
- System Stats
- Lookup IP Address
- Download Logs
As with all free services, there are limitations which can be eliminated via the paid service. For StatCounter.com, the limitation (at the time of this article) is the log will only hold up to 500 pageloads before knocking off the oldest hits. The Log determines the comprehensiveness of each of the above services. Please visit StatCounter for paid fees.
Because there are limitations, this free service is ideal for webmasters managing small sites with low to medium traffic. Visit Statcounter.com for a free demo before you sign up for a free account!
In most cases, designing a website will require some form of user validation. Some users will be granted more permissions than others, which complicates the process of testing and debugging. One method to ease this process is to impersonate a user of a different permission.
If users with access to the website can be trusted, perhaps a company intranet or home network, this easy method of user impersonation includes a value key combination in the WebConfig file (to read an article on Store Constant Variables in WebConfig). The high level idea is to create two keys to control user login. One is of the debugger’s username (yourAccount) and the second of the username you want to impersonate (accountToImpersonate).
<appSettings>
<add key = “currentDebugger” value = “yourAccount” />
<add key = “debuggerImpersonateAs” value = “accountToImpersonate” />
</appSettings>
With these appSettings, you want to create a function to manipulate the username before it is evaluated for permission levels. The function will switch the login username to accountToImpersonate whenever you log in as yourAccount allowing you specifiec access. Additionally, because the changes occur in the WebConfig file, changes can be made to the accountToImpersonate account without requiring a recompile.
public static string currentUser(string username)
{
if (username== ConfigurationSettings.AppSettings[”currentDebugger“])
username = ConfigurationSettings.AppSettings[”debuggerImpersonateAs“];
return username;
}
The function above will return either the username that is logged in or if you are the currentDebugger will return debuggerImpersonateAs. When the debug process is over, simply leave the currentDebugger value blank as shown below and you can log in as usual to yourAccount.
<appSettings>
<add key = “currentDebugger” value = “” />
<add key = “debuggerImpersonateAs” value = “accountToImpersonate” />
</appSettings>
An important security issue to keep in mind is that this method should only be used on website located on a trusted network. The important settings are saved in the WebConfig file, which can be altered without requiring a recompile, and therefore presents a potential security risk on open networks or the internet.
Not all variables will handle the value of null. Some of the variables that can be assigned null simply stored null as zero. Before, nullability is handled by implementing a try-catch block to catch nulls, assign a special variable (negative one for integers) to imply null, convert to any object to handle null, or even go as far as creating a class. There is now an easy way to enable any variable to handle nullability.
int? myInteger = null
To explain the above example, by placing a question mark (?) after the variable declaration, we are stating that this variable is nullable. If you have ever wondered: “What does that question mark after int”, or “What does that question mark after double” mean, now you know!
Variable nullability is especially useful in the case of database calls. A common situation where this is necessary is when the database call will return an integer value from a column that can be null. Everything works until a null row is returned and the project breaks at run time.
Next time you are making a call to database, try out this feature of C#.