Download the PHP package coversgift/facebook-pixel-capi without Composer

On this page you can find all versions of the php package coversgift/facebook-pixel-capi. 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 facebook-pixel-capi

Facebook Conversions API Service for Laravel

A simple Laravel package to send server-side events to the Facebook Conversions API (CAPI). This helps in tracking user actions more reliably, especially when browser-based tracking (like the Pixel) is blocked or limited.

Features

1. Installation

Since this is a local package, it's already integrated into your project. If it were a standard Composer package, you would run:

2. Configuration

a. Register Service Provider and Facade

The package's Service Provider and Facade must be registered in your config/app.php file. Your project already has this configured.

config/app.php

b. Publish Configuration File

To customize the configuration, publish the config file using the following Artisan command:

This command will create a config/facebookpixel.php file in your project, allowing you to manage settings centrally.

c. Set Environment Variables

Add the following keys to your .env file with your Facebook App credentials.

3. Usage

The primary way to use the service is through the FacebookPixel facade.

a. Capturing the _fbp Cookie (Frontend)

For accurate event matching and deduplication, it's crucial to send the _fbp (Facebook browser ID) cookie value with your server-side events. This value is created by the Facebook Pixel script on the user's browser.

You can capture it by adding a hidden input field to your forms and using a small JavaScript snippet to populate it.

1. Add a hidden input to your form:

2. Add the following JavaScript to your page:

This script will find the _fbp cookie and set its value to the hidden input field.

Now, when the form is submitted, the fbp value will be available in your controller via $request->fbp.

b. Sending an Event (Backend)

To send an event, call the sendPixelEvent method with an array of event data.

Event Data Parameters

The $eventData array should contain the following keys:

Key Required Description
event_name Yes The type of event (e.g., Purchase, AddToCart, ViewContent).
event_time Yes Unix timestamp of when the event occurred.
event_id Yes A unique ID for this specific event. Required for deduplication.
userID Yes The unique ID of the logged-in user in your system. Will be hashed.
phone Yes The user's phone number. Will be hashed.
fbp Yes The _fbp cookie from the user's browser. Helps with matching.
client_ip_address Yes The user's IP address.
client_user_agent Yes The user's browser user agent string.
value Yes The monetary value of the event (e.g., total order price).
currency Yes The currency code (e.g., BDT, USD).
content_ids Yes An array of product IDs associated with the event.
content_type Yes The type of content (usually product or product_group).
order_id Yes The unique ID for the order.
email No The user's email address. The service will hash it if provided.

4. Example: Tracking a Purchase Event

This example shows how to track a purchase event from a controller and ensure it's deduplicated with the browser-side Pixel event.

Controller (OrderController.php)

This is a simplified version of your placeOrder method, highlighting the CAPI integration steps.

View (thank-you.blade.php)

To prevent duplicate event counting, you must send the same event_id from both the server (CAPI) and the browser (Pixel).

This setup ensures that Facebook receives both events but understands they represent the same purchase, correctly deduplicating them in your Events Manager.


All versions of facebook-pixel-capi with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/http Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.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 coversgift/facebook-pixel-capi contains the following files

Loading the files please wait ....