How do I track info on external hyperlink on my site?

Ashok
Ashok used Ask the Experts™
on
My site is http://MySite.com (for example).

<asp:HyperLink
                ID="HyperLink2" runat="server" Height="44px"
                ImageUrl="~/Images/OrderOnline.png" NavigateUrl="http://ExternalSite.com">HyperLink</asp:HyperLink>

I have above link.
What I would like is every time someone clicks above link, I would like to insert a record
(MS SQL Server 2008 table) with Web Statistics (IP, timestamp and other info).

What is the best way to do this?

Thanks,
Ashok
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fixer of Problems
Most Valuable Expert 2014
Commented:
Convert this NavigateUrl="http://ExternalSite.com" into a link to one of your pages where you can record the info in your database and then redirect them to the real target page.
AshokSr. Software Engineer

Author

Commented:
DaveBaldwin,

I am not very expert in ASP.NET,
but I was thinking about that.

My only concern is how can I point to one of my page (dummy page with nothing in it), but stay on the current page and go to external website.

The link to external website is on the Home page
and I want to be able to click on it to go to external website, but if the user clicks back
it should come back to Home page.

Thanks,
Ashok
AshokSr. Software Engineer

Author

Commented:
if I redirect them to the real target page (from dummy page)

What will happen when user clicks on BACK button?

Will it show Home page?

Thanks,
Ashok
Dave BaldwinFixer of Problems
Most Valuable Expert 2014
Commented:
When you click on Back, you go to the last page Displayed in the browser.  If the redirect page does not display anything, then it will never be seen.  When you have done this, you will be a little more expert in ASP.NET.
AshokSr. Software Engineer

Author

Commented:
DaveBaldwin,

I will try this in next few days.
I have to learn fast from you experts.

I really appreciate your help.

Thanks a lot
Ashok
AshokSr. Software Engineer

Author

Commented:
Just implemented simple dummy page with Redirect
and
it working as expected.

Now I have to create table and write code to insert info.

Thanks,
Ashok
AshokSr. Software Engineer

Author

Commented:
DaveBaldwin,

Quick question.

If I enter code to insert into database after the Redirect statement, will it execute?

What is the best practice?

I was thinking I should redirect first so user sees the external page first then insert.

Thanks,
Ashok
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
I have always put it before.  I honestly don't know if the page continues executing after it sends the redirect, never done it that way.  The database insert should happen so quick they never know about it anyway.
AshokSr. Software Engineer

Author

Commented:
DaveBaldwin,

I have always put it before.  I honestly don't know if the page continues executing after it sends the redirect, never done it that way.

Good.

page DOES NOT EXECUTE after it sends the redirect....

So I put the Redirect last statement in Page_Load() method.

BTW, my web statics is now working perfectly.

Thanks,
Ashok
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
You're welcome, glad to help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial