PHP code example of eklundkristoffer / laravel-analytics
1. Go to this page and download the library: Download eklundkristoffer/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/ */
eklundkristoffer / 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 client secret json file. Take a look at the README of this package
* to learn how to get this file.
*/
'service_account_credentials_json' => storage_path('app/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,
/*
* Here you may configure the "store" that the underlying Google_Client will
* use to store it's data. You may also add extra parameters that will
* be passed on setCacheConfig (see docs for google-api-php-client).
*
* Optional parameters: "lifetime", "prefix"
*/
'cache' => [
'store' => 'file',
],
];