PHP code example of funnydevjsc / google-analytic-laravel-integrate
1. Go to this page and download the library: Download funnydevjsc/google-analytic-laravel-integrate 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/ */
funnydevjsc / google-analytic-laravel-integrate example snippets
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
// Other kernel properties...
/**
* The application's route middleware groups.
*
* @var array
*/
protected $routeMiddleware = [
// Other middlewares...
'google-analytic' => 'App\Http\Middleware\GoogleAnalyticMiddleware',
];
}
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
...
/**
* Bootstrap any application services.
*/
public function boot(): void
{
...
View::addNamespace('google-analytics', base_path('resources/views/vendor/google-analytics'));
View::share('clientId', Session::get('clientId') ?? '');
View::share('userData', Session::get('userData') ?? '');
}
}
bash
php artisan vendor:publish --provider="FunnyDev\GoogleAnalytic\GoogleAnalyticServiceProvider" --tag="google-analytic"
bash
php artisan google-analytic:crawl