PHP code example of tavp / analytics
1. Go to this page and download the library: Download tavp/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/ */
tavp / analytics example snippets
return [
'enabled' => true,
'track_page_views' => true,
'anonymize_ip' => true, // A2
'respect_dnt' => true, // A2
'respect_gpc' => true, // A2
'consent' => [ // A1
'enabled' => true,
'default_denied' => true,
'cookie_name' => 'tavp_consent',
'expiry_days' => 180,
'tcf_enabled' => true,
],
'retention' => [ // A4
'raw_days' => 395,
'aggregated_days' => 730,
'purge_batch_size' => 1000,
'auto_purge_enabled' => true,
'cron' => '0 2 * * *',
],
'queue' => [ // D1
'enabled' => false,
'connection' => 'analytics_redis',
'batch' => 100,
],
'ads' => [ // F2
'meta' => ['pixel_id'=>env('META_PIXEL_ID'), 'access_token'=>env('META_CAPI_TOKEN'), 'enabled'=>false],
],
];
// Tavp schedule: config/schedule.php -> Schedule->call(fn()=> (new PurgeAnalyticsCommand)->purge(), '0 2 * * *')
// Laravel: Kernel $schedule->command('analytics:purge --force')->dailyAt('02:00');
// Cron: 0 2 * * * cd /path && php artisan analytics:purge --force
bash
php vendor/bin/phpunit --testdox # 267 tests, 1138 assertions (v1.0.0)