jdorn/php-reports — pull request #165 by jdorn (2014-10-05 04:17:37+00:00)
Title: Google Analytics API Integration.

Adds Google Analytics API Integration so you can use GA data in your reports.

Google's Core Reporting documentation is helpful in getting started - https://developers.google.com/analytics/devguides/reporting/core/v3/

Usage
---------------
First, set the `ga_api` config parameters in `config/config.php`

```php
return array(
//...
'ga_api'=>array(
'applicationName'=>'PHP Reports',
'clientId'=>'abcd1234',
'clientSecret'=>'1234abcd',
'redirectUri'=>'http://example.com'
),
//...
);
```

You need to add a GA Authentication link somewhere in your `templates/local/html/page.twig` template (create this file if it doesn't exist). This example puts a link in the top nav.

```html+jinja
{% extends "default/html/page.twig" %}

{% block navbar %}
{{ parent() }}

{% if session.ga_token %} {% endif %}
GA Authenticate

{% endblock %}
```

Then in a PHP report:
```php
ga_data->get('ga:1234','2014-01-01','2014-02-01','ga:users',array(
'dimensions': 'ga:language'
));

//...
```