Web News


Canadian CIOs lash out at compliance pressures
Canadian CIOs say their efforts to bring IT systems into compliance with government regulations have made them far less efficient and have brought little value other than being able to say “no” to senior executives more often. A study released from Toronto-based...

Joost, JumpTV to join arms for 'ethnic' content
JumpTV, which offers "ethnic" television on the Net, said it will announce a deal Friday to offer some shows for free on online video service Joost. As expected, JumpTV will appear on Joost--initially with Spanish...

High fees prompt Canadians to leave cellphones on hold
The average cellphone bill is one-third more in Canada than in the United States, and although the price gap is closing, it continues to hinder the adoption of wireless communications in this country, a report to be released on Monday says. Just 56 per cent of Canadians...

Internet, blogs form new frontier for Quebec's...
There is nary a lamp-post in Quebec not sporting the smiling face of some hopeful candidate, and even the province's furthest outposts are being visited by rainbow-coloured campaign buses. But Quebec's...

B.C.'s video game industry weathers the storm
British Columbia's video game industry started 2006 ominously, with layoffs at the province's biggest employer, but recovered nicely to see established companies expand and new players emerge. But a major question mark hangs over the industry, which...

Nortel spin-off takes on Ethernet switch market
Blade Network Technologies, a server switch company spun out of Nortel last year, is hoping to take on network giants such as Cisco by offering switches with twice the performance of a standard blade server switch...

03.05.07


ASP.NET: Count Clicks On External Links

By Mads Kristensen

On a small test website I'm building in my spare time, I wanted a way to count the number of clicks to the outgoing links from that site.

Imaging hosting banners or other affiliate links where you get paid per click, it would be nice to know how many have clicked on them instead of relying on the advertiser's own statistics.

There are third-party products that can do it, but I would like to keep that data myself and it would be fun to build at the same time.

I came up with a very simple solution that uses a generic handler called redirect.ashx.

The handler registers the clicks in an XML file and is also able to print out the stats in a nice looking table.

It works by linking to redirect.ashx?url=http://example.com instead of http://example.com.

To get the stats from the handler, call it with the stats parameter redirect.ashx?stats=true.

That prints out a table with the statistics from each redirected URL.

Try a Better Way Today.
Try WebEx MeetMeNow -
Click Here

Crawlers and spiders

To avoid that the clicks made by crawlers and spiders, you can use this simple little trick that filters them out.

<a href="http://example.com" onclick="this.href='redirect.ashx?url='+this.href">Click here</a>

By using the onclick event on the link, all clients that don't support JavaScript will just follow the original URL and never hits the redirect.ashx file.

Implementation

Download the redirect.ashx handler below and put it somewhere in your web project. If your website doesn't already have an App_Code folder in the root, then add it. That's all you need to do. The handler automatically adds an XML file in the App_Code folder the first time it is hit and it automatically creates an XML node for every new URL it redirects.

Download

redirect.zip (1,48 KB)

Comments

About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/

About DevWebProCanada
DevWebProCanada is for professional developers ... those who build and manage applications and sophisticated websites. DevWebProCanada delivers via news and expert advice New Strategies In Development.

DevWebProCanada is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITmanagementNews.com


-- DevWebProCA is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2007 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal 


archives | advertising info | news headlines | free newsletters | comments/feedback | submit article


Delivering IT Solutions DevWebProCanada News Archives About Us Feedback DevWebProCanada Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact