views:

685

answers:

3

Hi

my client has a website that currently makes requests on a particular event (click, load etc). the website is working well and all but he has a problem with getting the website statistics with Google Analytics, the reason is, because the website never does a re-direct to a different page, it is all within the same page and no matter what event is loaded in the website(be it a video, tables etc) everything are displayed under the same url

www.somewebsite.com/default.aspx

what I want to achieve is on a particular event, change the url to

www.somewebsite.com/default.aspx?type=abc&id=999

How can I do this,. what is the easiest method to do this? please advise. The whole website is built in C#.

Many Thanks.

+1  A: 

Is this event happening on the server or the client?

If it's on the server, you can call Response.Redirect and add your new query string parameter to the current url.

If it's on the client (Javascript), you can set the location property.

SLaks
Yep i tried that too, but when I do response.redirect, it loads the homepage again, because basically all I am doing is hiding and showing elements based on events, if i do a response.redirect, it will reload teh homepage. :(
Mponnada
+1  A: 

If you want to preserve your page's state, try adding your querystring parameter to the form's action parameter in Javascript.

Alternatively, as jeffamaphone suggested, you can change the hash (the part after the # sign) by setting location.hash without posting back to the server.

SLaks
+1  A: 

Actually, you should probably move some of the elements to different pages... this is based on what you said:

because basically all I am doing is hiding and showing elements based on events, if i do a response.redirect, it will reload teh homepage.

If I understand correctly, the user is never redirected to a different page, you are just hiding/unhiding elements from default.aspx based in query strings... correct? the simplest solution will be to split that content into different aspx pages.

Ricardo