LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




ReplyREPLY THREAD
 
Thread Tools Display Modes
  #1  
Old 02-14-2008, 04:53 PM
[PAUL FERRIE]'s Avatar
[PAUL FERRIE] [PAUL FERRIE] is offline
Glasgow Flash Developer
 
Join Date: Feb 2005
Location: United Kingdom
Posts: 7,756
Rep Power: 16
[PAUL FERRIE] is on a distinguished road
Help getting average/total time on site

Hi guys,

My math is letting me down a bit and i am hoping someone here can help me.

Basicly i am trying to display the time spent on my site and the time spent on each section of the site. The site is built in flash and all the tracking is working as it should. It just tallying up the time is proving to be a headache.

When someone enter the site the tracker gets there ip and add's it to the db with timestamp. When the user continues to navigate the site the sections they visit are recorded in the db with timestamp and section id. This is the same for when they leave that section.

Below is the code i am using to retrieve the results.

PHP Code:

for($i=0$i $lastTen$i++) {

       
$visitorsD  mysql_fetch_array($visitorsC);
    
$visitorPagesA     mysql_query("SELECT * FROM visits WHERE uid = '".$visitorsD['id']."' ORDER BY id") or die(mysql_error());    
    
$output .= "&lastTen" $i "numViews="    mysql_num_rows($visitorPagesA);
    
$output .= "&lastTen" $i "lastVisit="    $visitorsD['date'] . " " $visitorsD['time'];
    
$output .= "&lastTen" $i "country="        ucWords(strToLower($visitorsD['country'])); 
    
$output .= "&lastTen" $i "browser="        $visitorsD['browser']; 
    
$output .= "&lastTen" $i "os="            $visitorsD['operatingSystem'];
    
$output .= "&lastTen" $i "entry="        $visitorsD['entryPage'];
    
//---------------------------------------------------------------------------------
    
$totTime 0;
    
$totalTime 0;
    
$time 0;
    
//---------------------------------------------------------------------------------
    
$userPageDate     split("/",$visitorsD['date']);
    
$dateID            $userPageDate[2]."-".$userPageDate[1]."-".$userPageDate[0];
    
$visitorPages     mysql_query("SELECT * FROM userpages WHERE  dateClicked = '".$dateID."' && ip ='".$visitorsD['ip']."'") or die(mysql_error());
    
$pagesClicked     mysql_num_rows($visitorPages);
    for(
$l 0$l $pagesClicked$l++){
        
$clicked      mysql_fetch_array($visitorPages);
        
//Time in section
        
$time    round($clicked['timeOnPage'] - $clicked['timeClicked'],1);
        
//Total time on site taking from adding time on section together
        
$totTime += $time;
        
//if time is less than 60 then treat as seconds
        
if($time<60){
            
$pageTime $time." secs";
        }else{
        
// if greater than 60 then dived and treat as minutes
            
$pageTimeround($time/60,1);
            if(
$pageTime<60){
                
$pageTime=$pageTime."mins";
            }else{
                
$pageTimeround($pageTime/60)."mins";
            }
        }
        
$output .= "&lastTen" $i "pages" $l "pageTitle=" $clicked['pageID'];
        
$output .= "&lastTen" $i "pages" $l "pageTime="  $pageTime;
    }
    if(
$totTime 60) {
        
$output .= "&lastTen" $i "totalTime=" $totTime " mins";
    } else {
        
$minsround($totTime/60);
        if(
$mins<60){
            
$output .= "&lastTen" $i "totalTime=" .$mins  " mins";
        }else{
            
$minsround($mins/60);
            
$output .= "&lastTen" $i "totalTime=" .$mins  " mins";
        }
    }
    
$output .= "&lastTen" $i "pagesClicked="$pagesClicked;

Can anyone point out where i am going wrong
__________________
.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher - Activeden

- bringmadeleinehome.com
Reply With Quote
  #2  
Old 02-15-2008, 02:20 PM
puppy's Avatar
puppy puppy is offline
Guide
 
Join Date: Dec 2002
Posts: 2,875
Rep Power: 13
puppy is on a distinguished road
and exact problem with it is...
__________________
Reply With Quote
  #3  
Old 02-15-2008, 03:26 PM
[PAUL FERRIE]'s Avatar
[PAUL FERRIE] [PAUL FERRIE] is offline
Glasgow Flash Developer
 
Join Date: Feb 2005
Location: United Kingdom
Posts: 7,756
Rep Power: 16
[PAUL FERRIE] is on a distinguished road
Nothing any more. I moved the caculations into flash and now have it working.
PHP Code:

for($l 0$l $pagesClicked$l++){

        
$clicked      mysql_fetch_array($visitorPages);
        
//Time in section
        
$time    round($clicked['timeOnPage'] - $clicked['timeClicked'],1);
        
//Total time on site taking from adding time on section together
        
$totTime += $time;
        
//if time is less than 60 then treat as seconds
        
$output .= "&lastTen" $i "pages" $l "pageTitle=" $clicked['pageID'];
        
$output .= "&lastTen" $i "pages" $l "pageTime="  $time;
    }
    
$output .= "&lastTen" $i "pagesClicked="$pagesClicked;
    
$output .= "&lastTen" $i "totalTime="$totTime
Actionscript:
onUpdateClock(totalPageTime);

function onUpdateClock(t:Number):Void {

	// to check against timer
	var i:Number = 0;

	// time
	var mins:Number = 0;
	var secs:Number = 0;


	while (i<t) {
		// set time in seconds
		i++;

		// get the leftovers of a division of 60 to update the seconds
		var secs = i%60;

		// if leftovers are ever 0 then increment the minute
		if (secs == 0) {
			mins++;
		}
	}
	//ouput result
	txTime.text = mins+":"+secs;
}
__________________
.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher - Activeden

- bringmadeleinehome.com
Reply With Quote


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
good and bad practice?? chasw7edinburgh Flash 8 2 10-03-2007 07:20 AM
different images every time user log onto my site RZA'77 Actionscript 2.0 2 12-05-2006 03:11 PM
Small flash site needed Loneaero Flash MX 5 11-25-2006 02:00 AM
Tell me if you think this is true yendor Members Cafe 4 11-24-2006 11:53 PM
this site has been around for some time Flashock Cool Sites 2 08-14-2000 01:19 PM




All times are GMT. The time now is 02:55 AM.