PHP code example of ahmedash95 / laravel-analytics
1. Go to this page and download the library: Download ahmedash95/laravel-analytics library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ahmedash95 / laravel-analytics example snippets
use Spatie\Analytics\Period;
//fetch the most visited pages for today and the past week
Analytics::fetchMostVisitedPages(Period::days(7));
//fetch visitors and page views for the past week
Analytics::fetchVisitorsAndPageViews(Period::days(7));
return [
/*
* The view id of which you want to display data.
*/
'view_id' => env('ANALYTICS_VIEW_ID'),
/*
* Path to the json file with service account credentials. Take a look at the README of this package
* to learn how to get this file.
*/
'service_account_credentials_json' => storage_path('app/laravel-google-analytics/service-account-credentials.json'),
/*
* The amount of minutes the Google API responses will be cached.
* If you set this to zero, the responses won't be cached at all.
*/
'cache_lifetime_in_minutes' => 60 * 24,
/*
* The directory where the underlying Google_Client will store it's cache files.
*/
'cache_location' => storage_path('app/laravel-google-analytics/google-cache/'),
];