PHP code example of clearanalytics / filament-clearanalytics

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

    

clearanalytics / filament-clearanalytics example snippets


use ClearAnalytics\Filament\ClearAnalyticsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugin(ClearAnalyticsPlugin::make());
}

->plugin(
    ClearAnalyticsPlugin::make()
        ->token(env('CLEARANALYTICS_API_TOKEN'))
        ->site('01JM...')        // default site id
        ->defaultPeriod('30d')
        ->cacheTtl(600)
        ->ecommerce(true)        // toggle the e-commerce widgets
        ->goals(true)            // toggle the goals widget
        ->live(false)            // toggle the live-visitors widget
        ->registerOnDashboard()  // also push selected widgets onto the panel's main dashboard
)

use ClearAnalytics\Filament\Widgets\OverviewStatsWidget;

protected function getHeaderWidgets(): array
{
    return [OverviewStatsWidget::class];
}

use ClearAnalytics\Filament\Facades\ClearAnalytics;

$overview = ClearAnalytics::overview(['period' => '30d', 'site_id' => '01JM...']);
$topPages = ClearAnalytics::pages(['period' => '7d', 'limit' => 20]);
bash
php artisan vendor:publish --tag="clear-analytics-config"
php artisan vendor:publish --tag="clear-analytics-translations"