PHP code example of teodoriu / laravel-analytics

1. Go to this page and download the library: Download teodoriu/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/ */

    

teodoriu / laravel-analytics example snippets


$start = \Illuminate\Support\Carbon::now()->startOfDay();
$end = \Illuminate\Support\Carbon::now()->endOfDay();

$totalUsers = Teodoriu\Analytics\Facades\Analytics::setDateRanges($start, $end)
                               ->setDimensions(
                                   [
                                       'hostName',
                                   ]
                               )
                               ->setMetrics(
                                   [
                                       'totalUsers',
                                   ]
                               )
                               ->runReport()
                               ->toArray();

return [

    /*
     * The view id of which you want to display data.
     */
    'property_id' => env('ANALYTICS_PROPERTY_ID', null),

    /*
     * 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,
];

Teodoriu\Analytics\Facades\Analytics::getAnalyticsService();
 bash
php artisan vendor:publish --provider="Teodoriu\Analytics\AnalyticsServiceProvider"