googleanalyticscounter Widget to show statistics of your website using Google Analytics API

  1. Requirements
  2. Usage
  3. Notice
  4. Charts
  5. Change log

This extention is a wrapper of GAPI (gapi-google-analytics-php-interface)
https://code.google.com/p/gapi-google-analytics-php-interface/

and optionally show statistics via yii-chartjs
http://www.yiiframework.com/extension/yii-chartjs/

Requirements

Yii
Google Analytics account
yii-chartjs [OPTIONAL]

Usage

1- Put this extension in your extensions folder.
2 - Put the following code in params.php

,'ga_email' => 'your@email.com'
,'ga_password' => 'yourpassword'
,'ga_profile_id' => 'profileid'

Notice

Notice: ga_profile_id is not the classic UA code, but is the Id of your site.

Enter in your google analytics account, example of url
https://www.google.com/analytics/web/?hl=it&pli=1#report/visitors-overview/a111111w22222p**987654321**/
987654321 is the Id of your site.

If you have BadAuthentication error go to this url:
https://accounts.google.com/DisplayUnlockCaptcha and unlock.

3 - Insert the following code in main.php

<?php $this->widget('ext.gaCounter.ExtGoogleAnalyticsCounter', array(
    'strTotalVisits' => 'Totale visite',
    'strDayVisits' => 'Visite giornaliere')
);?>


If you don't enter text in strTotalVisits or strDayVisits they don't appear.

Screenshot:
Screenshot

Charts

<?php
$this->widget('ext.gaCounter.ExtGoogleAnalyticsCounter', array(
        'lastYearChart' => true,
        'title' => 'Last year',
        'width' => 660,
        'height' => 300)
    );
    $this->widget('ext.gaCounter.ExtGoogleAnalyticsCounter', array(
        'lastMonthChart' => true,
        'title' => 'Last month',
        'width' => 400)
    );
    $this->widget('ext.gaCounter.ExtGoogleAnalyticsCounter', array(
        'customDateChart' => true,
        'startDate' => date('Y-m-d', strtotime('-1 week')),
        'endDate' => date("Y-m-d"),
        'typeChart' => 'day',  //day or month. Default is month
        'title' => 'Last week') //Optional
    );
?>

Screenshot:
Screenshot

Change log

Version 2.6

  • Use session for best performance.

    Version 2.5
  • Fix bug that calculate total visits
  • Moved config fields in params (thank you pmaselkowski)
6 0
12 followers
959 downloads
Yii Version: Unknown
License: BSD-2-Clause
Category: Others
Developed by: sepu
Created on: Oct 18, 2013
Last updated: 4 years ago

Downloads

show all

Related Extensions