ideacrafters/laravel-pixels-manager

The Laravel Pixel Manager is a comprehensive package designed to simplify the integration and management of multiple advertising platform pixels (Facebook, TikTok, Snapchat, Pinterest, Twitter/X) in Laravel applications

Fund package maintenance!
ideacrafters

Installs: 8

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 1

pkg:composer/ideacrafters/laravel-pixels-manager

1.0.1 2025-11-01 15:39 UTC

This package is auto-updated.

Last update: 2025-11-01 15:53:17 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

A unified package for managing multiple advertising platform pixels (Facebook, TikTok, Snapchat) in Laravel applications with server-side conversion tracking.

Features

  • 📊 Multi-Platform Support: Built-in support for Facebook, TikTok, and Snapchat
  • 🎯 Selective Targeting: Target specific platforms or pixels for each event
  • 🔄 Queue-Based Processing: Zero performance impact with async event processing
  • 🔒 Secure Credentials: AES-256 encryption for access tokens
  • 🛡️ GDPR/CCPA Compliant: Built-in consent management
  • 📝 Blade Directives: Easy-to-use directives for script injection
  • Smart Deduplication: Prevent duplicate events with cache-based deduplication

Installation

You can install the package via composer:

composer require ideacrafters/laravel-pixels-manager

Run the installation wizard:

php artisan pixel:install

Add your first pixel:

php artisan pixel:add

Usage

Basic Tracking

Track events across all configured platforms:

use Ideacrafters\PixelManager\Facades\PixelManager;

PixelManager::track('Purchase', [
    'value' => 99.99,
    'currency' => 'USD',
]);

Selective Tracking

Track to specific platforms:

PixelManager::forPlatforms('facebook', 'tiktok')
    ->track('ViewContent', [
        'content_id' => 'SKU123',
        'value' => 29.99,
    ]);

Track to specific pixels:

PixelManager::forPixels(1, 3)
    ->track('AddToCart', [
        'content_id' => 'SKU123',
        'value' => 29.99,
    ]);

Exclude platforms:

PixelManager::except('snapchat')
    ->track('PageView');

Blade Directives

Add to your layout's <head> section:

<head>
    @pixels
    <!-- Your other head content -->
</head>

Load specific platforms:

@pixels('facebook', 'tiktok')

Add noscript fallbacks:

<noscript>
    @pixelsNoscript
</noscript>

Model Integration

Add the TrackableEvents trait to your User or Order model:

use Ideacrafters\PixelManager\Traits\TrackableEvents;

class User extends Authenticatable
{
    use TrackableEvents;
}

Now track events directly on your models:

$user->trackPurchase(99.99, 'USD');
$user->trackAddToCart($product->id, $product->price);
$user->trackViewContent($product->id, $product->name, $product->price);

Artisan Commands

# Install and setup
php artisan pixel:install

# Add a new pixel
php artisan pixel:add

# Test a pixel configuration
php artisan pixel:test {id}

Configuration

The configuration file includes:

  • Platform adapter mappings
  • Queue connection settings
  • Deduplication settings
  • Standard event definitions
  • Cache configuration

See config/pixels-manager.php for all available options.

Requirements

  • PHP >= 8.0
  • Laravel >= 9.0
  • Queue driver: Redis (recommended) or Database
  • Cache driver: Redis (recommended) or Memcached

Testing

composer test

Security

  • AES-256 encryption for credentials stored in database
  • SHA-256 hashing for PII (emails, phones) before sending
  • HTTPS-only API communication
  • Input validation and sanitization
  • GDPR/CCPA consent management

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.