### Install package via Composer
Source: https://github.com/combindma/laravel-facebook-pixel/blob/main/README.md
Run this command to install the laravel-facebook-pixel package using Composer.
```bash
composer require combindma/laravel-facebook-pixel
```
--------------------------------
### Register MetaPixelMiddleware globally
Source: https://github.com/combindma/laravel-facebook-pixel/blob/main/README.md
Add the middleware globally in your application's bootstrap configuration to enable flash functionality.
```php
->withMiddleware(function (Middleware $middleware) {
$middleware->append(MetaPixelMiddleware::class);
})
```
--------------------------------
### Publish views with artisan vendor:publish
Source: https://github.com/combindma/laravel-facebook-pixel/blob/main/README.md
Optionally publish the package views using this artisan command.
```bash
php artisan vendor:publish --tag="meta-pixel-views"
```
--------------------------------
### Publish config file with artisan vendor:publish
Source: https://github.com/combindma/laravel-facebook-pixel/blob/main/README.md
Publish the config file using this artisan command.
```bash
php artisan vendor:publish --tag="meta-pixel-config"
```
--------------------------------
### Assign MetaPixelMiddleware to routes
Source: https://github.com/combindma/laravel-facebook-pixel/blob/main/README.md
Recommended for admin routes; assign the middleware to a route group to limit its application.
```php
Route::group(['middleware' => [MetaPixelMiddleware::class]], static function () {
});
```
--------------------------------
### Published config file (meta-pixel.php)
Source: https://github.com/combindma/laravel-facebook-pixel/blob/main/README.md
The published config file contains settings for pixel_id, session_key, token, app_secret, advanced_matching_enabled, enabled, logging, and test_event_code. Adjust these values in your .env file.
```php
return [
/*
* The Meta pixel id, should be a code that looks something like "1202417153106158".
*/
'pixel_id' => env('META_PIXEL_ID', ''),
/*
* The key under which data is saved to the session with flash.
*/
'session_key' => env('META_PIXEL_SESSION_KEY', config('app.name').'_metaPixel'),
/*
* Only if you plan using Conversions API for server events
* To use the Conversions API, you need an access token. For Documentation please see: https://developers.facebook.com/docs/marketing-api/conversions-api/get-started
*/
'token' => env('META_PIXEL_TOKEN', ''),
/*
* Your Meta App Secret, required to generate a valid appsecret_proof for the Conversions API.
* Found in your Meta App Dashboard under Settings > Basic.
*/
'app_secret' => env('META_PIXEL_APP_SECRET'),
/*
* Enable or disable advanced matching. Useful for adjusting user privacy.
*/
'advanced_matching_enabled' => env('META_PIXEL_ADVANCED_MATCHING_ENABLED', true),
/*
* Enable or disable script rendering. Useful for local development.
*/
'enabled' => env('META_PIXEL_ENABLED', false),
/*
* Enable or disable logging. Useful for debugging.
*/
'logging' => env('META_PIXEL_LOGGING', false),
/*
* This is used to test server events
*/
'test_event_code' => env('META_TEST_EVENT_CODE'),
];
```
--------------------------------
### HTML head and body tags with new Blade components
Source: https://github.com/combindma/laravel-facebook-pixel/blob/main/upgrade-v4-to-v5.md
Use this HTML structure to integrate the new Blade components in your layout. The