PHP code example of fojlerabbirabib / laravel-spa-analytics
1. Go to this page and download the library: Download fojlerabbirabib/laravel-spa-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/ */
fojlerabbirabib / laravel-spa-analytics example snippets
Route::fallback(fn () => abort(404));
use FojleRabbiRabib\LaravelSpaAnalytics\Models\AnalyticsSession;
AnalyticsSession::query()->notBots()->between($from, $to)->get(); // between() uses started_at
use FojleRabbiRabib\LaravelSpaAnalytics\Contracts\BotDetector;
public function register(): void
{
$this->app->bind(BotDetector::class, MyDeviceDetectorBotDetector::class);
}
use FojleRabbiRabib\LaravelSpaAnalytics\Data\Query\FunnelStep;
use FojleRabbiRabib\LaravelSpaAnalytics\Enums\RollupDimension;
use FojleRabbiRabib\LaravelSpaAnalytics\Enums\RollupPeriod;
use FojleRabbiRabib\LaravelSpaAnalytics\Facades\Stats;
$report = Stats::between($from, $to); // or Stats::lastDays(7)
$report->summary(); // Summary
$report->timeseries(RollupPeriod::Day); // SeriesPoint[]
$report->top(RollupDimension::Path, 10); // TopRow[]
$report->goals(); // GoalRow[]
$report->funnel([ // Funnel
FunnelStep::path('/pricing'),
FunnelStep::event('clicked_signup'),
FunnelStep::goal('signup'),
]);
Stats::realtime(); // Realtime