Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

Can any one tell, what to do to get the average time on .aspx page ?

average time: the time spent by visitor on a page....

i have written the below script to start my seconds timer on page load... and every time i have stored it in a hidden asp field.......

C#
<script type="text/javascript">
           var tick = 0;
           function timer() {
               alert('time');
               var time = setInterval(function () {
                   tick = tick + 1;

                   document.getElementById("<%=lbltimer.ClientID%>").value = tick;

               }, 1000);

           }

           </script>


the problem is how can i find the page visit is over and user changed to other page,....... is there any event for it in aspx? so that i can call the hidden field stored time in that method ....and know the time spent on page from load to end...
Posted
Updated 6-Jun-13 21:34pm
v2

1 solution

I think this would be appropriate for you..
Page Tracking in ASP.NET[^]
Also see..
http://forums.asp.net/t/1231152.aspx/1[^]
 
Share this answer
 
v2
Comments
Ashok Reddy K 7-Jun-13 5:34am    
hi thanx....the 2nd link contains the similar problem like mine....but there count is taken on button click event , but here i want on page change, i.e once the visitor changes to other page i want to calculate the time....for this i need to know when the page has been left by the visitor... is there any aspx change event for this...or any other solution
ridoy 7-Jun-13 5:43am    
i think page close event may be your choice..search in google for that..
ridoy 7-Jun-13 5:44am    
You can see..
http://forums.asp.net/t/1615156.aspx/1?ASP+NET+C+page+close+event+
http://stackoverflow.com/questions/2101634/asp-net-page-close-event-in-asp-net
http://stackoverflow.com/questions/16584663/how-to-detect-the-page-close-event-with-asp-net

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900