Skip to content
CodeIgniter Library to connect Google Analytics API.
PHP
Branch: master
Clone or download
Thejan Rajapakshe
Thejan Rajapakshe remove IDE files
Latest commit 74f7174 Jul 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
controllers added missing controller example class Apr 10, 2015
libraries Initialize Mar 20, 2015
LICENSE Initial commit Mar 20, 2015
README.md Update README.md May 1, 2019

README.md

GoogleAnalytics-CodeIgniter

CodeIgniter Library to connect Google Analytics API.

Installation

  1. Copy config/ga_api.php file to the config folder of your application.
  2. Copy GoogleAnalytics.php file and google-api-php-client folder to the library folder of your application.

Usage

  1. Load the config file to your controller $this->config->load('ga_api');
  2. Load the library & config values
$ga_params = array(
          'applicationName' => $this->config->item('ga_api_applicationName'),
           'clientID' => $this->config->item('ga_api_clientId'),
          'clientSecret' => $this->config->item('ga_api_clientSecret'),
          'redirectUri' => $this->config->item('ga_api_redirectUri'),
           'developerKey' => $this->config->item('ga_api_developerKey'),
           'profileID' => $this->config->item('ga_api_profileId')
       );
 $this->load->library('GoogleAnalytics', $ga_params);

Get Total Values

  • $this->googleanalytics->get_total('users') returns total number of users visited to your page.
  • $this->googleanalytics->get_total({metric}) {metric} = users, newUsers, percentNewSessions, sessionsPerUser.

Get Dimensional Values

  • $this->googleanalytics->get_dimensions('browser','users') returns array of number of users visited to your page with browsers.
  • $this->googleanalytics->get_dimensions({dimension},{matric}) {metric} = users, newUsers, percentNewSessions, sessionsPerUser. {dimension} = browser, browserVersion, operatingSystem, operatingSystemVersion, mobileDeviceBranding, mobileDeviceModel, mobileInputSelector, mobileDeviceInfo, mobileDeviceMarketingName, deviceCategory.

Dimensions & Metrics Reference

Logout

$this->googleanalytics->logout(); Destroys the session.

You can’t perform that action at this time.