PHP code example of eflyax / facebook-pixel

1. Go to this page and download the library: Download eflyax/facebook-pixel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

eflyax / facebook-pixel example snippets


abstract class BaseFrontPresenter extends BasePresenter
{

    /** @var IFacebookPixelFactory @inject */
    public $IFacebookPixelFactory;
    
    /** @var FacebookPixel */
    public $facebookPixel;
    
    
    protected function startup()
    {
        parent::startup();
        $this->facebookPixel = $this['facebookPixel'];
    }

    
    .
    .
    
    protected function createComponentFacebookPixel()
    {
        return $this->IFacebookPixelFactory->create();
    }
    
}

    $this->facebookPixel->addToCart(
        $productId,
        $productTitle,
        $productCategory,
        $productPrice,
        $currencyCode
    );


$this->facebookPixel->viewContent(
    $productId,
    $productTitle,
    $productCategory,
    $productPrice,
    $currencyCode
);

$this->facebookPixel->viewContent(
    $productIds
);

  $this->facebookPixel->purchase($totalPrice, $currencyCode);