Download the PHP package bkfdev/laravel-facebook-pixel without Composer
On this page you can find all versions of the php package bkfdev/laravel-facebook-pixel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bkfdev/laravel-facebook-pixel
More information about bkfdev/laravel-facebook-pixel
Files in bkfdev/laravel-facebook-pixel
Package laravel-facebook-pixel
Short Description Facebook Pixel integration for Laravel
License MIT
Homepage https://github.com/aeq-dev/laravel-facebook-pixel
Informations about the package laravel-facebook-pixel
Facebook Pixel integration for Laravel
A Complete Facebook Pixel implementation for your Laravel application.
Introduction
This package provides a smooth integration of Meta Pixel, along with a straightforward implementation of the latest Conversions API, enhancing your overall experience.
Pre-requisites
Register a Meta Pixel
To get started with the pixel Meta, you must have a Meta pixel registered: Read this guide.
Conversions API
If you plan to use Conversions API then you need to:
Obtain An Access Token
To use the Conversions API, you need to generate an access token, which will be passed as a parameter in every API call.
Refer to Conversions API Guide to learn more.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
If you plan on using the flash-functionality you must install the FacebookPixelMiddleware, after the StartSession middleware:
Usage - Meta Pixel
Include scripts in Blade
Insert head view after opening head tag, and body view after opening body tag
Your events will also be rendered here. To add an event, use the track()
function.
This renders:
You can also specify a unique event ID for any of your events so that, if you plan using the conversions API you avoid duplications.
Flashing data for the next request
The package can also set event to render on the next request. This is useful for setting data after an internal redirect.
After a form submit, the following event will be parsed on the contact page:
Available Methods
Custom Events
You can also track a specific custom event on your website. This feature is not available for flashed events.
This renders:
Advanced matching
This package provides by default advanced matching. We retrieve the email and the user id from authenticated user and include it in the Pixel base code fbq('init') function call as a third parameter.
Macroable
Adding events to pages can become a repetitive process. Since this package isn't supposed to be opinionated on what your events should look like, the FacebookPixel is macroable.
Usage - Conversions API
If you plan on using Conversions API functionalities. Yous should specify the token in your .env file first.
For every request yous should specify a unique event id for handling Pixel Duplicate Events and Conversions API.
This is how you can start:
If you don't specify the $user_data parameter, by default we retrieve the email & the id from Auth::user() if the user is authenticated. We use the user id as a same external_id in Meta Pixel and conversions API
If you want to test server events, you need to specify the FACEBOOK_TEST_EVENT_CODE in your .env file. By default, this test code will be sent in all API request.
So Don't forget to delete after you finish your server tests.
You can use the Playload Helper to learn more about the requests to send.
Testing
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Bkfdev
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-facebook-pixel with dependencies
facebook/php-business-sdk Version ^16.0
illuminate/contracts Version ^9.0|^10.0
spatie/laravel-package-tools Version ^1.11