This package is for Laravel and shows pageviews and other data from Google Analytics in your admin page. You only need setup the credentials to communicate with Google Analytics.
add this to your composer.json
"require": {
"abr4xas/GoogleAnalytics": "dev-master"
}
and
$ composer update
$ composer dump-autoload -o // optional
Next up the service provider must be registered:
'providers' => [
...
Spatie\Analytics\AnalyticsServiceProvider::class,
Abr4xas\GoogleAnalytics\GoogleAnalyticsServiceProvider::class,
];
...
'aliases' => [
...
'Analytics' => Spatie\Analytics\AnalyticsFacade::class,
...
];
Next up routes:
//Google Analytics
Route::get('analytics', 'AnalyticsController@index')->name('analytics');
Route::get('analytics-mobile', 'AnalyticsController@mobile')->name('analytics-mobile');
Route::get('analytics-returning', 'AnalyticsController@newreturningsessions')->name('analytics-returning');
Route::get('analytics-operating', 'AnalyticsController@operatingsystem')->name('analytics-operating');
Route::get('analytics-traffic', 'AnalyticsController@traffic')->name('analytics-traffic');
Route::get('analytics-time-on-site', 'AnalyticsController@timeonsite')->name('analytics-time-on-site');
Route::get('analytics-referring-sites', 'AnalyticsController@referringsites')->name('analytics-referring-sites');
Route::get('analytics-search-engines', 'AnalyticsController@searchengines')->name('analytics-search-engines');
Route::get('analytics-keywords', 'AnalyticsController@keywords')->name('analytics-keywords');
Route::get('analytics-topcontent', 'AnalyticsController@topcontent')->name('analytics-topcontent');
Route::get('analytics-top-landing-pages', 'AnalyticsController@toplandingpages')->name('analytics-top-landing-pages');
Route::get('analytics-top-exit-pages', 'AnalyticsController@topexitpages')->name('analytics-top-exit-pages');
Follow the instruction at spatie/laravel-analytics and add download a json file and save as a service-account-credentials.json under storage/app/googleanalytics/
folder.
Add ANALYTICS_VIEW_ID
to .env
file.
Add Chart.js to header.
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-line-chart"></i>
{{ trans('googleanalytics::googleanalytics.analytics') }}
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>
<a href="{{ route('analytics') }}">
<i class="fa fa-pie-chart"></i>
<span>{{ trans('googleanalytics::googleanalytics.analyticsbasic') }}</span>
</a>
</li>
<li>
<a href="{{ route('analytics-mobile') }}">
<i class="fa fa-table"></i>
<span>{{ trans('googleanalytics::googleanalytics.mobile-traffic') }}</span>
</a>
</li>
<li>
<a href="{{ route('analytics-returning') }}">
<i class="fa fa-table"></i>
<span>{{ trans('googleanalytics::googleanalytics.returningsessions') }}</span>
</a>
</li>
<li>
<a href="{{ route('analytics-operating') }}">
<i class="fa fa-table"></i>
<span>{{ trans('googleanalytics::googleanalytics.operatingsystem') }}</span>
</a>
</li>
<li>
<a href="{{ route('analytics-traffic') }}">
<i class="fa fa-table"></i>
<span>{{ trans('googleanalytics::googleanalytics.trafficsources') }}</span>
</a>
</li>
<li>
<a href="{{ route('analytics-time-on-site') }}">
<i class="fa fa-table"></i>
<span>{{ trans('googleanalytics::googleanalytics.timeonsite') }}</span>
</a>
</li>
<li>
<a href="{{ route('analytics-referring-sites') }}">
<i class="fa fa-table"></i>
<span>{{ trans('googleanalytics::googleanalytics.referringsites') }}</span>
</a>
</li>
<li>
<a href="{{ route('analytics-search-engines') }}">
<i class="fa fa-table"></i>
<span>{{ trans('googleanalytics::googleanalytics.searchengines') }}</span>
</a>
</li>
<li>
<a href="{{ route('analytics-keywords') }}">
<i class="fa fa-table"></i>
<span>{{ trans('googleanalytics::googleanalytics.keywords') }}</span>
</a>
</li>
<li>
<a href="{{ route('analytics-topcontent') }}">
<i class="fa fa-table"></i>
<span>{{ trans('googleanalytics::googleanalytics.topcontent') }}</span>
</a>
</li>
<li>
<a href="{{ route('analytics-top-landing-pages') }}">
<i class="fa fa-table"></i>
<span>{{ trans('googleanalytics::googleanalytics.toplandingpages') }}</span>
</a>
</li>
<li>
<a href="{{ route('analytics-top-exit-pages') }}">
<i class="fa fa-table"></i>
<span>{{ trans('googleanalytics::googleanalytics.topexitpages') }}</span>
</a>
</li>
</ul>
</li>
Please see CHANGELOG for more information on what has changed recently.
$ composer test
Please see CONTRIBUTING and CONDUCT for details.
The MIT License (MIT). Please see License File for more information.