thujohn / analytics-l4 by thujohn

Google Analytics for Laravel 4
108,001
111
17
Package Data
Maintainer Username: thujohn
Maintainer Contact: jonathan.thuau@gmail.com (Jonathan Thuau)
Package Create Date: 2013-06-20
Package Last Update: 2015-09-11
Language: PHP
License: MIT
Last Refreshed: 2024-11-14 15:06:57
Package Statistics
Total Downloads: 108,001
Monthly Downloads: 174
Daily Downloads: 6
Total Stars: 111
Total Watchers: 17
Total Forks: 33
Total Open Issues: 21

Analytics

Port of Laravel 3 bundle lordcoste/analytics-s2s for Laravel 4

Build Status

Installation

Add thujohn/analytics to composer.json.

"thujohn/analytics": "dev-master"

Run composer update to pull down the latest version of Analytics.

Now open up app/config/app.php and add the service provider to your providers array.

'providers' => array(
    'Thujohn\Analytics\AnalyticsServiceProvider',
)

Now add the alias.

'aliases' => array(
    'Analytics' => 'Thujohn\Analytics\AnalyticsFacade',
)

Configuration

Run php artisan config:publish thujohn/analytics and modify the config file with your own informations.

Usage

Querying the API for visits and pageviews in the last week.

More information about this calling the Google Analytics API can be found here https://developers.google.com/apis-explorer/#s/analytics/v3/analytics.data.ga.get A list of all Google Analytics metrics can be found here https://developers.google.com/analytics/devguides/reporting/core/dimsmets

$site_id = Analytics::getSiteIdByUrl('http://github.com/'); // return something like 'ga:11111111'

$stats = Analytics::query($site_id, '7daysAgo', 'yesterday', 'ga:visits,ga:pageviews');