Wednesday, August 7, 2013

Google Analytics cookie parser using PHP

Google Analytics collects data using first-party cookies who are stored on our browsers. I’ve programmed a PHP class we can use to read Google Analytics __utma and __utmz cookies. This class can be used to easily integrate this cookie data into proprietary systems like CRM, ERP, Helpdesks, etc.
  • __utma (expires 2 years after being defined) – visitor dataThis cookie is written on your first visit to the website. In case you erase it its created again. Its used for the Unique Visitors calculation and is updated on every pageview.
  • __utmz (expires 6 months after being defined) – campaign dataThis cookie stores informations on how the user got to our website: referrer, direct (none), organic or a campaign such as a newsletter. (since you tag it correctly using the URL Builder). This cookie is overwritten every time you visit the website.
The Google Analytics Cookie Parser allows you to obtain some data contained in this cookies in a human readable format.
  • Campaign source
  • Campaign name
  • Campaign medium
  • Campaign content
  • Campaign term
  • Date of first visit
  • Date of previous visit
  • Date of current visit
  • Times visited
  • Pages viewed

Download the latest version of Google Analytics PHP cookie parser from Github.
https://github.com/joaolcorreia/Google-Analytics-PHP-cookie-parser

Popular Posts