https://github.com/m2quared/laravel-google-analytics
📊 Google Analytics for Laravel
https://github.com/m2quared/laravel-google-analytics
google-analytics laravel laravel-5-package laravel-google-analytics
Last synced: 3 months ago
JSON representation
📊 Google Analytics for Laravel
- Host: GitHub
- URL: https://github.com/m2quared/laravel-google-analytics
- Owner: m2quared
- License: mit
- Created: 2016-06-28T09:40:22.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-02-02T12:15:33.000Z (over 2 years ago)
- Last Synced: 2025-02-01T05:41:17.621Z (3 months ago)
- Topics: google-analytics, laravel, laravel-5-package, laravel-google-analytics
- Language: PHP
- Homepage:
- Size: 12.7 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Google Analytics
Port of Laravel 4 bundle [thujohn/analytics](https://github.com/thujohn/analytics-l4) for Laravel 5+
## Installation
Add `m2quared/laravel-google-analytics` to `composer.json`.
"m2quared/laravel-google-analytics": "^1.0"
Run `composer update` to pull down the latest release of Laravel Google Analytics.Now open up `config/app.php` and add the service provider to your `providers` array.
```php
'providers' => [
M2quared\Analytics\AnalyticsServiceProvider::class,
]
```Now add the alias.
```php
'aliases' => [
'Analytics' => M2quared\Analytics\AnalyticsFacade::class,
]
```## Configuration
Run `php artisan vendor:publish` and modify the config file `config/google-analytics.php` with your own information.
## 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
```php
$site_id = Analytics::getSiteIdByUrl('http://github.com/'); // return something like 'ga:11111111'$stats = Analytics::query($site_id, '7daysAgo', 'yesterday', 'ga:visits,ga:pageviews');
```