PHP code example of revoltify / pixelify

1. Go to this page and download the library: Download revoltify/pixelify 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/ */

    

revoltify / pixelify example snippets


use Revoltify\Pixelify\Contracts\PixelifyUserInterface;
use Revoltify\Pixelify\Traits\HasPixelifyUser;

class User extends Model implements PixelifyUserInterface
{
    use HasPixelifyUser;

    // overwrite methods if needed
    public function getPixelFirstName(): ?string
    {
        return $this->name;
    }
}

use Revoltify\Pixelify\Contracts\PixelifyProductInterface;
use Revoltify\Pixelify\Traits\HasPixelifyProduct;

class Product extends Model implements PixelifyProductInterface
{
    use HasPixelifyProduct;

    // overwrite methods if needed
    public function getPixelProductCurrency(): string
    {
        return $this->product_currency;
    }
}

use Revoltify\Pixelify\Facades\Pixelify;

// Track page view
Pixelify::pageView($user->toPixelUser());

// Track view content
Pixelify::viewContent(
    $product->toPixelProduct(),
    $user->toPixelUser()
);

// Track add to cart
Pixelify::addToCart(
    $product->toPixelProduct(),
    $user->toPixelUser()
);

// Track initiate checkout
Pixelify::initiateCheckout(
    $product->toPixelProduct(),
    $user->toPixelUser()
);

// Track purchase
Pixelify::purchase(
    $product->toPixelProduct(),
    $user->toPixelUser()
);

use Revoltify\Pixelify\DTO\UserData;
use Revoltify\Pixelify\DTO\ProductData;

$userData = new UserData(
    firstName: 'John',
    lastName: 'Doe'
    email: '[email protected]',
    phone: '+1234567890',
);

$productData = new ProductData(
    productId: '123',
    price: 99.99,
    quantity: 1,
    currency: 'USD'
);

Pixelify::purchase($productData, $userData);
bash
php artisan pixelify:setup