PHP code example of particle-academy / fancy-heuristics

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

    

particle-academy / fancy-heuristics example snippets


use FancyHeuristics\Facades\Heuristics;

Heuristics::record($event);                 // persist one event
Heuristics::collect($payload, $ua);         // persist a batch + upsert its session
Heuristics::ping($ping);                    // persist a pixel liveness beacon
Heuristics::heatmap($siteKey, $path);       // normalised grid of pointer/click hits
Heuristics::events($siteKey, [...]);        // raw events, filtered
Heuristics::sessionStats($siteKey);         // sessions + counts by actor & kind

Heuristics::acquisition($site, 30);                  // referrer hosts, utm, direct vs referral
Heuristics::audience($site, 30);                     // device / browser / os / language
Heuristics::timeseries($site, 30, 'day', false);     // sessions+pageviews per bucket (day|week|month)
Heuristics::sessionsSummary($site, 30);              // totals, avg duration, bounce rate, pages/session
Heuristics::topPages($site, 30);                     // top paths by pageviews
Heuristics::entryPages($site, 30);                   // landing pages by session
Heuristics::exitPages($site, 30);                    // exit pages by session
Heuristics::topElements($site, 30);                  // most-clicked target_id / label
Heuristics::realtime($site);                         // sessions active in the last 5 minutes

// bootstrap/app.php
use Illuminate\Console\Scheduling\Schedule;

->withSchedule(function (Schedule $schedule) {
    $schedule->command('heuristics:verify-pixels')
        ->cron(config('heuristics.verify.cron')); // default 03:00 & 15:00
})
bash
composer vendor:publish --tag=heuristics-config      # optional
php artisan vendor:publish --tag=heuristics-migrations  # optional (auto-loaded otherwise)
php artisan migrate