PHP Classes


Recommend this page to a friend!
  Classes of Alexander Skakunov   PHP Google Analytics API Metrics Tracker   Download  
Role: Documentation
Content type: text/markdown
Description: documentation
Class: PHP Google Analytics API Metrics Tracker
Track accesses to your API using Google Analytics
Author: By
Last change: added a screenshot
Date: 8 years ago
Size: 1,467 bytes


Class file image Download

This class helps to track your backend application usage in Google Analytics -- the requests made to your backend are logged in Google Analytics.

this is how it looks

Technically it uses the Mobile Tracking class content is here

The class is done for my project.

You can reach me at .


The class is based on Zend Framework 1, so if you don't want to use it, the request\response\cookies management must be re-implemented in this class.


  1. Register at Google Analytics and get a tracking ID that looks like "UA-111111-11"
  2. Edit your application config and paste this line: = UA-111111-11

  3. make sure you add this plugin in application/Bootstrap.php:

    protected function _initPlugins() { $front = Zend_Controller_Front::getInstance(); $front->registerPlugin(new Yasno_Controller_Plugin_Integration_Google_Analytics_Mobile_Tracker); }

That's it. You will have your backend script usage stats in Google Analytics in a while.


Clients of your API can set parameter "partner-id" and that will be used to track different users.