PHP code example of vincentbean / laravel-plausible

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

    

vincentbean / laravel-plausible example snippets


<x-plausible::tracking />
or
<x-plausible::tracking extensions="hash, outbound-links, etc.." />

// app/Http/Kernel.php
    'web' => [
        // Add this middleware to the web group to track globally
        \VincentBean\Plausible\Middleware\TrackPlausiblePageviews::class,
    ],

\VincentBean\Plausible\Events\PlausibleEvent::fire('custom event', ['country' => 'netherlands']);

\VincentBean\Plausible\Events\PlausibleEvent::fire('custom event', ['country' => 'netherlands'], headers: [
    'X-Forwarded-For' => $event->userIp,
    'user-agent' => $event->userAgent
]);
bash
php artisan vendor:publish --provider="VincentBean\Plausible\LaravelPlausibleServiceProvider" --tag="config"