weblagence / laravel-facebook-pixel
Facebook Pixel integration for Laravel
Installs: 83 024
Dependents: 0
Suggesters: 0
Security: 0
Stars: 36
Watchers: 5
Forks: 14
Open Issues: 5
Requires
- php: ~7.1
Requires (Dev)
- phpunit/phpunit: >=7.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-10-19 22:36:34 UTC
README
Facebook Pixel integration for Laravel
An easy Facebook Pixel implementation for your Laravel application.
Facebook Pixel
The Facebook pixel is a snippet of JavaScript code that allows you to track visitor activity on your website. It works by loading a small library of functions which you can use whenever a site visitor takes an action (called an event) that you want to track (called a conversion). Tracked conversions appear in the Facebook Ads Manager and in the Facebook Analytics dashboard, where they can be used to measure the effectiveness of your ads, to define custom audiences for ad targeting, for dynamic ads campaigns, and to analyze that effectiveness of your website's conversion funnels.
For concrete examples of what you want to send throught the Standard Events
Install
You can install the package via Composer:
composer require weblagence/laravel-facebook-pixel
In Laravel 5.5 and up, the package will automatically register the service provider and facade
In L5.4 or below start by registering the package's the service provider and facade:
// config/app.php 'providers' => [ ... WebLAgence\LaravelFacebookPixel\LaravelFacebookPixelServiceProvider::class, ], 'aliases' => [ ... 'LaravelFacebookPixel' => WebLAgence\LaravelFacebookPixel\LaravelFacebookPixelFacade::class, ],
Next, publish the config file:
php artisan vendor:publish --provider="WebLAgence\LaravelFacebookPixel\LaravelFacebookPixelServiceProvider"
Configuration
The configuration file is fairly simple.
return [ /* * The Facebook Pixel id, should be a code that looks something like "XXXXXXXXXXXXXXXX". */ 'facebook_pixel_id' => '', /* * Use this variable instead of `facebook_pixel_id` if you need to use multiple facebook pixels */ 'facebook_pixel_ids' => [], /* * Enable or disable script rendering. Useful for local development. */ 'enabled' => true, ];
Usage
Basic Example
First you'll need to include Facebook Pixel's script. Facebook's docs recommend doing this right after the body tag.
{{-- layout.blade.php --}}
<html>
<head>
@include('facebook-pixel::head')
{{-- ... --}}
</head>
<body>
@include('facebook-pixel::body')
{{-- ... --}}
</body>
</html>
Send pixel
At any moment, you can use the next function to create a Standard Event
\LaravelFacebookPixel::createEvent($eventName, $parameters = []);
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email jeremy@weblagence.com instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.