PHPackages                             gillbeits/yii2-google-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. gillbeits/yii2-google-api

ActiveLibrary[API Development](/categories/api)

gillbeits/yii2-google-api
=========================

Google Api Component for Yii2

28.3k1[2 issues](https://github.com/gillbeits/yii2-google-api/issues)[1 PRs](https://github.com/gillbeits/yii2-google-api/pulls)PHP

Since Mar 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/gillbeits/yii2-google-api)[ Packagist](https://packagist.org/packages/gillbeits/yii2-google-api)[ RSS](/packages/gillbeits-yii2-google-api/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Google Api Component for Yii2
=============================

[](#google-api-component-for-yii2)

---

[![Latest Stable Version](https://camo.githubusercontent.com/fe5417623972f0117973226cfc7a35e275d3c13c46e3eb164cdb8acd82c350b9/68747470733a2f2f706f7365722e707567782e6f72672f67696c6c62656974732f796969322d676f6f676c652d6170692f762f737461626c652e737667)](https://packagist.org/packages/gillbeits/yii2-google-api)[![Total Downloads](https://camo.githubusercontent.com/42eceb26e2d1926d7d02e2a5339a0be19fdd68a0563a7883765594094c4320d0/68747470733a2f2f706f7365722e707567782e6f72672f67696c6c62656974732f796969322d676f6f676c652d6170692f646f776e6c6f6164732e737667)](https://packagist.org/packages/gillbeits/yii2-google-api)[![Latest Unstable Version](https://camo.githubusercontent.com/b5c1dc77452455c0d36ec77e8c97d18ff863e649807570cb6232cfc380af8eb7/68747470733a2f2f706f7365722e707567782e6f72672f67696c6c62656974732f796969322d676f6f676c652d6170692f762f756e737461626c652e737667)](https://packagist.org/packages/gillbeits/yii2-google-api)[![License](https://camo.githubusercontent.com/e9da0b9c67f19ac1ff48a74e631aafbc99d021888012bbb84bc31ef5b84460d3/68747470733a2f2f706f7365722e707567782e6f72672f67696c6c62656974732f796969322d676f6f676c652d6170692f6c6963656e73652e737667)](https://packagist.org/packages/gillbeits/yii2-google-api)

Installation
------------

[](#installation)

The preferred way to install this component is through [composer](http://getcomposer.org/download/).

```
php composer.phar require --prefer-dist gillbeits/yii2-google-api

```

\###Configuration
-----------------

[](#configuration)

in your app and/or console configuration file, add

```
'components' => [
    // Google Api Configuration
    'google-api'   => [
        'class'             => 'gillbeits\Yii2GoogleApi\GoogleApi',
        'credentials' => '@common/config/google-api-server-key.json',
        'services' => [
            'analytics' => [
                'class' => '\Google_Service_Analytics',
                'scopes' => ['https://www.googleapis.com/auth/analytics.readonly']
            ],
            ...
        ]
    ],
    ...
],
```

Usage
-----

[](#usage)

```
// Get Sessions by user gender dimension
$data = \Yii::$app->{'google-api'}
        ->analytics
            ->data_ga
                ->get(
                    "ga:",
                    "2015-01-01",
                    "today",
                    "ga:sessions",
                    [
                       "dimensions" => "ga:userGender"
                    ]
                )
;
```

Widgets
-------

[](#widgets)

For usage widgets in Yii2 install yiisoft/yii2-bootstrap library:

```
php composer.phar require yiisoft/yii2-bootstrap
```

- Google Analytics widget usage

    ```
