Link to home
Start Free TrialLog in
Avatar of Ashok
AshokFlag for United States of America

asked on

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

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
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ashok

ASKER

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
Avatar of Ashok

ASKER

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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ashok

ASKER

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
Avatar of Ashok

ASKER

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
Avatar of Ashok

ASKER

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
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.
Avatar of Ashok

ASKER

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
You're welcome, glad to help.