Skip to content
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

Open
berberon opened this issue Jan 17, 2014 · 3 comments
Open

active visitors #8

berberon opened this issue Jan 17, 2014 · 3 comments

Comments

@berberon
Copy link

Hi

active visitors increase with each call to autoload.php.
Is this something that need to be corrected server side?

@emmanuelgautier
Copy link

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);

@berberon
Copy link
Author

berberon commented Feb 6, 2014

Hi

Thanks for your reply.
I'm not clear about why after "$visitor = new GoogleAnalytics\Visitor();" you do "$visitor->setUniqueId(false);".

Where do you set "$visitor->setUniqueId" ?

@berberon
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants