serversidegoogleanalytics


Server Side Google Analytics (PHP)

This project isn't activly maintained anymore. If you're looking for a more advanced and up to date library, please have a look at the php-ga project from Thomas Bachem: http://code.google.com/p/php-ga

Server Side Google Analytics (SSGA) is a simple PHP 5 class, which allows to track server-side events and data within Google Analytics.

Requirements

  • PHP 5.2 or up
  • Zend Framework (only for the http client; can be replaced by curl)

Usage

Download and include the class in your source files.

Create a new instance of the class
$ga = new Elements_Tools_Serversideanalytics();

Set your Google Analytics key
$ga->setAccountId("UA-1234567-8");

Set your charset
$ga->setCharset("UTF-8");

Set your hostname
$ga->setHostName("www.example.com");

Set page title
$ga->setPageTitle("Test");

Set language
$ga->setLanguage("de");

Set a pageview
$ga->setPageView("/de/serverside/test");

Set an event (based on http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html'>http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html)
$ga->setEvent("Category", "Action", "Label", "Value");

Submit an event
$ga->createEvent();

Project Information

  • License: GNU GPL v3
  • 47 stars
  • svn-based source control

Labels:
Analytics serversideanalytics serversidetracking webanalytics