PHP code example of mehdiyev-signal / pixel-manager

1. Go to this page and download the library: Download mehdiyev-signal/pixel-manager library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mehdiyev-signal / pixel-manager example snippets


'event_mappings' => [
    'purchase' => ['meta', 'google', 'tiktok', 'brevo', 'pinterest', 'snapchat'],
    'add_to_cart' => ['meta', 'google', 'tiktok', 'brevo', 'pinterest', 'snapchat'],
    'view_item' => ['meta', 'google', 'tiktok', 'brevo'],
    'search' => ['meta', 'google'],
    // Add more event mappings...
],

use MehdiyevSignal\PixelManager\Presentation\Facades\PixelManager;

PixelManager::track([
    'data' => [
        'event_type' => 'purchase',
        'event' => 'purchase',
        'transaction_id' => 'TXN123456',
        'order_id' => 'ORD789',
        'value' => 99.99,
        'currency' => 'USD',
        'shipping' => 5.00,
        'customer' => [
            'email' => '[email protected]',
            'external_id' => 'user_12345',
            'first_name' => 'John',
            'last_name' => 'Doe',
            'phone' => '+1234567890',
            'city' => 'New York',
            'state' => 'NY',
            'country_code' => 'US',
            'zip_code' => '10001',
        ],
        'items' => [
            [
                'item_id' => 'PROD123',
                'item_name' => 'Premium Widget',
                'price' => 49.99,
                'quantity' => 2,
                'category' => 'Electronics',
                'item_brand' => 'BrandName',
            ]
        ]
    ]
]);

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use MehdiyevSignal\PixelManager\Presentation\Facades\PixelManager;

class EventController extends Controller
{
    public function track(Request $request)
    {
        PixelManager::track($request->all());

        return response()->json(['success' => true]);
    }
}

// Get all supported platforms
$platforms = PixelManager::platforms();
// Returns: ['meta', 'google', 'brevo', 'tiktok', 'pinterest', 'snapchat']

// Check if a platform is enabled
if (PixelManager::isPlatformEnabled('meta')) {
    // Meta pixel is configured and enabled
}

use MehdiyevSignal\PixelManager\Infrastructure\Persistence\MongoDB\Models\CustomerEventModel;

$events = CustomerEventModel::where('event_name', 'purchase')
    ->where('created_at', '>=', now()->subDay())
    ->get();
bash
php artisan vendor:publish --tag=pixel-manager-config
bash
php artisan vendor:publish --tag=pixel-manager-migrations
php artisan migrate
bash
php artisan queue:work --queue=pixel-events