2017 © Pedro Peláez
 

library google-analytics

Laravel Google Analytics

image

ozankurt/google-analytics

Laravel Google Analytics

  • Monday, July 17, 2017
  • by OzanKurt
  • Repository
  • 5 Watchers
  • 76 Stars
  • 4,543 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 5 Versions
  • 6 % Grown

The README.md

Google Analytics

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Connecting to your analytics account and getting whatever data you need was never this easy. :sunglasses:, (*2)

Installation

Step 1

Add ozankurt/google-analytics to your composer requirements., (*3)

composer require ozankurt/google-analytics

Step 2

Configure ozankurt/google-core package by following its README., (*4)

Step 3

Select the Analytics API, (*5)

Select the Analytics API, (*6)

Enable it, (*7)

Enable It, (*8)

Step 4

Add analytics scope to your scopes array to the configurations in ozankurt/google-core package., (*9)

'scopes' => [
    'https://www.googleapis.com/auth/analytics.readonly',
],

Usage (Laravel)

Step 1

Add analytics.viewId to your config/google.php., (*10)

    /**
     * View ID can be found in `http://google.com/analytics` under the `Admin` tab on navigation.
     *
     * Select `Account`, `Property` and `View`. You will see a `View Settings` link.
     */
    'analytics' => [
        'viewId' => 'ga:12345678',
    ],

Controller Example

use Kurt\Google\Analytics\Analytics as GoogleAnalytics;

class GoogleController extends Controller
{
    private $ga;

    function __construct(GoogleAnalytics $ga) {
        $this->ga = $ga;
    }

    public function index()
    {
        $results = $this->ga->getUsersAndPageviewsOverTime();

        var_dump($results);
    }
}

Usage (Pure PHP)

Example

<?php

require 'vendor/autoload.php';

use Kurt\Google\Core\Core;
use Kurt\Google\Analytics\Analytics;

$googleCore = new Core([
    'applicationName'       => 'Google API Wrapper Demo',
    'jsonFilePath'          => 'Google API Wrapper Demo-174e172143a9.json',
    'scopes' => [
        Google_Service_Analytics::ANALYTICS_READONLY,
    ],
    'analytics' => [
        'viewId' => 'ga:97783314'
    ],
]);

$analytics = new Analytics($googleCore);

$results = $analytics->getUsersAndPageviewsOverTime();

var_dump($results);

Results

Both of these examples will give a result like this., (*11)

The result of GoogleController@index should look like this:, (*12)

array (size=2)
    'cols' => 
        array (size=2)
            0 => string 'ga:sessions' (length=11)
            1 => string 'ga:pageviews' (length=12)
    'rows' => 
        array (size=1)
            0 => array (size=2)
                'ga:sessions' => string '100' (length=3)
                'ga:pageviews' => string '250' (length=3)

License

This open-sourced is software licensed under the MIT license., (*13)

The Versions

17/07 2017

dev-master

9999999-dev

Laravel Google Analytics

  Sources   Download

MIT

The Requires

 

laravel api service analytics google

27/01 2017

v2.0.1

2.0.1.0

Laravel Google Analytics

  Sources   Download

MIT

The Requires

 

laravel api service analytics google

04/11 2016

v2.0

2.0.0.0

Laravel Google Analytics

  Sources   Download

MIT

The Requires

 

laravel api service analytics google

04/11 2016

2.0.x-dev

2.0.9999999.9999999-dev

Laravel Google Analytics

  Sources   Download

MIT

The Requires

 

laravel api service analytics google

09/07 2015

v1.0

1.0.0.0

Laravel 5 Google Analytics

  Sources   Download

MIT

The Requires

 

laravel api service analytics google