setono/meta-conversions-api-php-sdk

PHP library with basic objects and more for working with Facebook/Metas Conversions API

v0.2.4 2023-11-20 12:21 UTC

README

Latest Version Software License Build Status Code Coverage Mutation testing

Installation

The easiest way to install this library is by installing the library along with its HTTP client dependencies:

composer require setono/meta-conversions-api-php-sdk kriswallsmith/buzz nyholm/psr7

If you want to use your own HTTP client, just do composer require setono/meta-conversions-api-php-sdk and then remember to set the HTTP client and factories when instantiating the Setono\MetaConversionsApi\Client\Client

Usage

use Setono\MetaConversionsApi\Event\Event;
use Setono\MetaConversionsApi\Pixel\Pixel;

$event = new Event(Event::EVENT_VIEW_CONTENT);
$event->eventSourceUrl = 'https://example.com/products/blue-jeans';
$event->userData->clientUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36';
$event->userData->email[] = 'johndoe@example.com';
$event->pixels[] = new Pixel('INSERT YOUR PIXEL ID', 'INSERT YOUR ACCESS TOKEN');
// $event->testEventCode = 'test event code'; // uncomment this if you want to send a test event

$client = new Client();
$client->sendEvent($event);