Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Name: Universal Analytics Cookie Parser Class
- * Description: Parses the new format Universal Analytics cookie.
- * Developer: Matt Clarke
- * Date: January 10, 2013
- */
- class UniversalAnalyticsCookieParser{
- // Parse the _ga cookie if found
- function __construct() {
- if( isset($_COOKIE["_ga"]) ){
- echo $this->getCid();
- }
- }
- // Handle the parsing of the _ga cookie
- public function parseCookie()
- {
- list($version,$domainDepth, $cid1, $cid2) = split('[\.]', $_COOKIE["_ga"],4);
- return array('version' => $version, 'domainDepth' => $domainDepth, 'cid' => $cid1.'.'.$cid2);
- }
- // Get cid
- public function getCid()
- {
- $contents = $this->parseCookie();
- return $contents['cid'];
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment