定制 revoltify/pixelify 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

revoltify/pixelify

最新稳定版本:2.1.0

Composer 安装命令:

composer require revoltify/pixelify

包简介

Laravel package for Facebook Conversion API integration

README 文档

README

Latest Version on Packagist Total Downloads Tests PHP 8.2+ Laravel Version

A Laravel package for easy integration with Facebook Conversion API to track various events like ViewContent, PageView, AddToCart, InitiateCheckout, and Purchase.

Installation

For Laravel 11+

composer require revoltify/pixelify "^2.0"

For Laravel 9+

composer require revoltify/pixelify "^1.0"

Configuration

Publish the configuration file:

php artisan pixelify:setup

Add your Facebook Pixel credentials to your .env file:

FACEBOOK_PIXEL_ID=your_pixel_id
FACEBOOK_CONVERSION_API_TOKEN=your_api_token
FACEBOOK_TEST_EVENT_CODE=your_test_event_code (optional)
FACEBOOK_PIXEL_DEBUG=false

Getting Your Facebook Pixel ID and Access Token

  1. Go to Facebook Events Manager
  2. Select your Pixel
  3. Go to the "Settings" tab
  4. Copy the Dataset ID (this is your Pixel ID)
  5. Scroll down to "Set up direct integration"
  6. Click "Generate access token"
  7. Copy the generated Pixel Access Token

Usage

Model Integration

Implement the interfaces in your models:

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;
    }
}

Tracking Events

use App\Models\User;
use App\Models\Product;
use Revoltify\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);

Using DTOs Directly

You can also create DTOs manually:

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

$userData = new UserData(
    firstName: 'John',
    lastName: 'Doe',
    email: 'user@example.com',
    phone: '+1234567890',
);

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

Pixelify::purchase($productData, $userData);

Testing

composer test

Contributing

Thank 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.

License

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

统计信息

  • 总下载量: 72
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固