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

Replaced split with preg_split. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions class.gaparse.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
// Version 1.0 - Date: 17 September 2009
// Version 1.1 - Date: 25 January 2012
// Version 1.2 - Date: 21 April 2012
// Version 1.3 - Date: 12 June 2013
//
// Define a PHP class that can be used to parse
// Google Analytics cookies currently with support
// for __utmz (campaign data) and __utma (visitor data)
//
// Author: Joao Correia - http://joaocorreia.pt
// Contrib by: Dan Garfield - http://todaywasawesome.com
//
// License: LGPL
//
Expand Down Expand Up @@ -69,22 +71,17 @@ function ParseCookies(){
// Parse the __utma Cookie
list($domain_hash,$random_id,$time_initial_visit,$time_beginning_previous_visit,$time_beginning_current_visit,$session_counter) = preg_split('[\.]', $_COOKIE["__utma"]);

$this->first_visit = new \DateTime();
$this->first_visit->setTimestamp($time_initial_visit);

$this->previous_visit = new \DateTime();
$this->previous_visit->setTimestamp($time_beginning_previous_visit);

$this->current_visit_started = new \DateTime();
$this->current_visit_started->setTimestamp($time_beginning_current_visit);

$this->first_visit = date("d M Y - H:i",$time_initial_visit);
$this->previous_visit = date("d M Y - H:i",$time_beginning_previous_visit);
$this->current_visit_started = date("d M Y - H:i",$time_beginning_current_visit);
$this->times_visited = $session_counter;

// Parse the __utmb Cookie

list($domain_hash,$pages_viewed,$garbage,$time_beginning_current_session) = preg_split('[\.]', $_COOKIE["__utmb"]);
$this->pages_viewed = $pages_viewed;

// The __utmb Cookie is only set by the 2nd visit.
if(isset($_COOKIE["__utmb"])){
list($domain_hash,$pages_viewed,$garbage,$time_beginning_current_session) = preg_split('[\.]', $_COOKIE["__utmb"]);
$this->pages_viewed = $pages_viewed;
}

// End ParseCookies
}
Expand Down