Download the PHP package setono/meta-conversions-api-bundle without Composer

On this page you can find all versions of the php package setono/meta-conversions-api-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package meta-conversions-api-bundle

Meta / Facebook Conversions API bundle

Latest Version Build Status

Work with the Meta / Facebook Conversions API in your Symfony application. Under the hood this bundle integrates the Meta Conversions API PHP SDK library.

Requirements

Installation

The SDK sends events through a PSR-18 client and PSR-17 factories, which it discovers automatically. If your application does not already ship both, install them alongside the bundle:

The SDK depends on php-http/discovery, which contains a Composer plugin. Composer asks whether to allow it, and either answer works. To skip the prompt (e.g. in CI) declare it in your composer.json:

Installing the bundle also installs the Bot Detection Bundle, which is used to filter bot requests.

If you want to handle consent (i.e. cookie/GDPR consent), install the consent bundle and enable the consent option (see Configuration):

Upgrading from 0.1.x? See UPGRADE.md.

Configuration

All options with their defaults:

Route the command to a transport

Server side events are dispatched on your application's default Messenger bus. The bundle does not register a bus of its own, so your bus configuration is left untouched. Point the bundle at another bus with the server_side.message_bus option if you prefer.

Route the command to an async transport. Without it, Messenger handles the command synchronously, which means the http call to Meta happens inside the visitor's request: their page waits for Meta's round trip, and Meta's availability becomes your availability.

With a transport, Messenger also retries a failed send and moves it to the failure transport when it keeps failing.

Either way, a send that fails is logged as an error and never propagates into the response, so an expired access token or an outage at Meta cannot break the page.

Usage

How it works

Dispatching a ConversionsApiEventRaised runs the event through a pipeline of listeners. The bundle populates the event first, then leaves a gap for your own listeners, then filters and sends:

Priority Listener What it does
PRIORITY_POPULATE (1000) PopulateRequestPropertiesSubscriber Source url, client ip and user agent from the request
900 PopulateFbpAndFbcPropertiesSubscriber fbp and fbc
800 PopulateTestEventCodePropertySubscriber Test event code
650 FilterEmptyUserAgentSubscriber Stops events without a user agent
625 FilterConfiguredUserAgentsSubscriber Stops events matching filters.user_agent
PRIORITY_FILTER (600) FilterBotsSubscriber Stops events from bots
500 PopulatePixelsSubscriber Pixels from the pixel provider
PRIORITY_ENRICH (0) your listeners Email, phone, external id, custom data
-950 StopPropagationIfNoPixelsHasBeenAddedSubscriber Stops events without pixels
PRIORITY_SEND (-1000) AddEventToTagBagSubscriber Renders the fbq() calls (client side)
PRIORITY_SEND (-1000) DispatchOnCommandBusSubscriber Dispatches SendEvent (server side)

Two things follow from this:

The constants live on ConversionsApiEventRaised, so you can position your listener without hard coding a number.

Enriching an event

Everything the Conversions API can do beyond the browser pixel comes from the user data you attach server side. Meta normalises and hashes it for you, so set the raw values:

You can also replace a step instead of adding to it: alias PixelProviderInterface, FbpContextInterface or FbcContextInterface to your own service, or register a listener above the corresponding populate priority.

Why did my event not show up?

Every listener that drops an event says so at debug level on the setono_meta_conversions_api Monolog channel: the bot filter, the user agent filters, the no-pixels check, and each of the three consent gates. The send handler logs a warning when a pixel has no access token.

Events that are not raised in a browser request

The pipeline assumes the event belongs to the request being handled. PopulateRequestPropertiesSubscriber therefore fills in the source url, client ip and user agent of the current request, and the bot and user agent filters only apply to events whose actionSource is website (the default).

For an event raised from a console command, a message handler or an incoming webhook, set another action source so the filters leave it alone:

If such an event is raised while handling an HTTP request, for instance a webhook from your payment provider, the request properties still describe that request, not the customer. Overwrite them in a listener above PRIORITY_POPULATE when they matter.

Giving Meta its own timeout

Because the client is a normal service, a scoped client works out of the box:

Note that a scoped client is a Symfony HttpClientInterface, so wrap it for PSR-18:

Graph API version

Events are posted to the Graph API version of the installed facebook/php-business-sdk package (the SDK reads ApiConfig::APIVersion): v26.0 with the 26.x package, v25.0 with 25.x. To move to a newer Graph API version simply run composer update facebook/php-business-sdk.

Test the integration

Take the test event code from Meta / Facebook's event manager and append it to any url on your website: https://example.com/?_testEventCode=[YOUR TEST EVENT CODE] (or ?_test_event_code=[YOUR TEST EVENT CODE]). The code is saved in the session, so all your subsequent requests are sent with it. Clear it again with an empty value: https://example.com/?_testEventCode=.

Because anyone who can add a query parameter would otherwise be able to divert their own conversions into the test bucket, the query parameter is only honoured when test_event_code.query_parameter is enabled. It follows kernel.debug by default, so it works in dev and is off in prod. To send every event as a test event, for instance from a staging environment, set test_event_code.value instead.


All versions of meta-conversions-api-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
composer/semver Version ^3.0
psr/log Version ^1.1 || ^2.0 || ^3.0
setono/bot-detection-bundle Version ^1.7
setono/consent-contracts Version ^1.1
setono/meta-conversions-api-php-sdk Version ^2.0.0-beta.2
symfony/config Version ^6.4 || ^7.4
symfony/dependency-injection Version ^6.4 || ^7.4
symfony/event-dispatcher Version ^6.4 || ^7.4
symfony/event-dispatcher-contracts Version ^3.0
symfony/http-foundation Version ^6.4 || ^7.4
symfony/http-kernel Version ^6.4 || ^7.4
symfony/messenger Version ^6.4 || ^7.4
symfony/service-contracts Version ^2.5 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package setono/meta-conversions-api-bundle contains the following files

Loading the files please wait ...