-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
active visitors #8
Comments
you can save the session of the visitor and the visitor himself saving Session and Visitor Object. For example : if(isset($_SESSION['ga-visitor'])){
$now = new DateTime();
$visitor = unserialize($_SESSION['ga-visitor']);
$visitor->setCurrentVisitTime($now);
} else {
$visitor = new GoogleAnalytics\Visitor();
$visitor->setUniqueId(false);
}
$_SESSION['ga-visitor'] = serialize($visitor);
if(isset($_SESSION['ga-session'])){
$session = unserialize($_SESSION['ga-session']);
$visitor->addSession($session);
} else {
$session = new GoogleAnalytics\Session();
}
$_SESSION['ga-session'] = serialize($session); |
Hi Thanks for your reply. Where do you set "$visitor->setUniqueId" ? |
This is What i have now. Am i doing this right? setCurrentVisitTime($now); }else{ $visitor = new GoogleAnalytics\Visitor(); // $visitor->setUniqueId(false); $SSID=session_id(); $visitor->setUniqueId($SSID); $visitor->setIpAddress($_SERVER['REMOTE_ADDR']); $visitor->setUserAgent($_SERVER['HTTP_USER_AGENT']); } $_SESSION['ga-visitor'] = serialize($visitor); if(isset($_SESSION['ga-session'])){ $session = unserialize($_SESSION['ga-session']); $visitor->addSession($session); } else { $session = new GoogleAnalytics\Session(); } $_SESSION['ga-session'] = serialize($session); // Assemble Page information $page = new GoogleAnalytics\Page($GA_PAGE_NAME); $page->setTitle($GA_TITLE); // Track page view $tracker->trackPageview($page, $session, $visitor); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
active visitors increase with each call to autoload.php.
Is this something that need to be corrected server side?
The text was updated successfully, but these errors were encountered: