A Laravel package for easy integration with Facebook Conversion API to track various events like ViewContent, PageView, AddToCart, InitiateCheckout, and Purchase.
For Laravel 11+
composer require revoltify/pixelify "^2.0"For Laravel 9+
composer require revoltify/pixelify "^1.0"Publish the configuration file:
php artisan pixelify:setupAdd your Facebook Pixel credentials to your .env file:
FACEBOOK_PIXEL_ID=your_pixel_idFACEBOOK_CONVERSION_API_TOKEN=your_api_tokenFACEBOOK_TEST_EVENT_CODE=your_test_event_code (optional)FACEBOOK_PIXEL_DEBUG=false- Go to Facebook Events Manager
- Select your Pixel
- Go to the "Settings" tab
- Copy the Dataset ID (this is your Pixel ID)
- Scroll down to "Set up direct integration"
- Click "Generate access token"
- Copy the generated Pixel Access Token
Implement the interfaces in your models:
useRevoltify\Pixelify\Contracts\PixelifyUserInterface;
useRevoltify\Pixelify\Traits\HasPixelifyUser;
class User extends Model implements PixelifyUserInterface
{
use HasPixelifyUser;
// overwrite methods if neededpublicfunctiongetPixelFirstName(): ?string
{
return$this->name;
}
}
useRevoltify\Pixelify\Contracts\PixelifyProductInterface;
useRevoltify\Pixelify\Traits\HasPixelifyProduct;
class Product extends Model implements PixelifyProductInterface
{
use HasPixelifyProduct;
// overwrite methods if neededpublicfunctiongetPixelProductCurrency(): string
{
return$this->product_currency;
}
}useApp\Models\User;
useApp\Models\Product;
useRevoltify\Pixelify\Facades\Pixelify;
$user = User::first();
$product = Product::first();
// Track page view
Pixelify::pageView($user);
// Track view content
Pixelify::viewContent($product, $user);
// Track add to cart
Pixelify::addToCart($product, $user);
// Track initiate checkout
Pixelify::initiateCheckout($product, $user);
// Track purchase
Pixelify::purchase($product, $user);You can also create DTOs manually:
useRevoltify\Pixelify\DTO\UserData;
useRevoltify\Pixelify\DTO\ProductData;
useRevoltify\Pixelify\Facades\Pixelify;
$userData = newUserData(
firstName: 'John',
lastName: 'Doe',
email: 'user@example.com',
phone: '+1234567890',
);
$productData = newProductData(
productId: '123',
price: 99.99,
quantity: 1,
currency: 'USD'
);
Pixelify::purchase($productData, $userData);composer testThank you for considering contributing to the Pixelify package! We welcome all contributions, including bug reports, feature requests, and pull requests.
Please review existing issues and pull requests before submitting your own to avoid duplicates.
If you discover any security-related issues, please email info@revoltify.net directly instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.