2017 © Pedro Peláez
 

library gacookie

image

jflight/gacookie

  • Monday, January 2, 2017
  • by jamesflight
  • Repository
  • 2 Watchers
  • 6 Stars
  • 6,044 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 1 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

Google-Analytics-Cookie-Parser-PHP

Build Status, (*1)

This tool converts google's utmz and utma cookies into easy to use objects., (*2)

This gives easy access to googel session and keyword data., (*3)

Installation

Install via composer. Edit your project's composer.json file to require jflight/gacookie:, (*4)

"require": {
    "jflight/gacookie":"dev-master"
}

Update Composer from the terminal:, (*5)

composer update

Usage

Parse the cookies (currently supports utma and utmz):, (*6)

<?php

use Jflight\GACookie\GACookie;

$utma = GACookie::parse('utma');
$utmz = GACookie::parse('utmz');

Or directly parse strings:, (*7)

<?php

$utma = GACookie::parseString('utma', '177910838.254655113.1474876189.1482142331.1482148790.58');
$utmz = GACookie::parseString('utmz', '177910838.1481550491.52.15.utmcsr=newsletter|utmccn=campaign-2016|utmcmd=email');

You can now access cookie variables:, (*8)

For utma, (*9)

<?php

$utma->time_of_first_visit; // DateTime
$utma->time_of_last_visit; // DateTime
$utma->time_of_current_visit; // DateTime
$utma->session_count // Integer

For utmz, (*10)

<?php

$utmz->timestamp; // DateTime
$utmz->session_count // Integer
$utmz->campaign_number // Integer
$utmz->source // string
$utmz->medium // string
$utmz->campaign // string
$utmz->term // string
$utmz->content // string

Because all time related properites return DateTime objects, this sort of thing is possible:, (*11)

<?php

echo $utma->time_of_first_visit->format('Y'); // e.g. 2014

Also if you are so inclined, properties can be accessed via ArrayAccess:, (*12)

<?php

echo $utmz['source']; // e.g. google

The Versions

02/01 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by James Flight

02/01 2017

2.0

2.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by James Flight

28/03 2014

0.9.2

0.9.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by James Flight

28/03 2014

1.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by James Flight

28/03 2014

0.9.1

0.9.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by James Flight

28/03 2014

0.9

0.9.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by James Flight