formatz / meta-conversions-api-php-sdk

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

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

About

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

License:MIT License


Languages

Language:PHP 100.0%