2017 © Pedro Peláez
 

library facebook-pixel

Facebook pixel for Nette

image

eflyax/facebook-pixel

Facebook pixel for Nette

  • Wednesday, November 8, 2017
  • by Eflyax
  • Repository
  • 1 Watchers
  • 3 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 45 % Grown

The README.md

Nette extension for Facebook Pixel.

TODO * support for ajax, (*1)

Requirements

Installation

The best way to install Eflyax/Facebook-pixel is using Composer:, (*2)

$   composer require eflyax/facebook-pixel

Usage

Preparation

Extension registration

Add to your neon config:, (*3)

extensions:
    facebookPixel: Eflyax\FacebookPixel\DI\FacebookPixelExtension

and configuration with you FB pixel ID:, (*4)

facebookPixel:
    id: '111122223333444'
    productIdPrefix: '42' # optional

Be careful you add FB pixel ID as string, there was issues with integer, (*5)

Backend

Inject FB pixel factory and service to your module where you want to render FB pixel. FB pixel service will help you to render specific events., (*6)

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

}

Frontend

Now you are ready to render FB pixel in layout, (*7)

{control facebookPixel}, (*8)

Events

AddToCart

In method where you add product to cart call eventStart like this:, (*9)

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

Purchase

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

ViewContent

For one product:, (*10)

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

For more products (category):, (*11)

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

Events validation

If you want to validate events which you send to facebook I can recommend this browser plugin: Facebook Pixel Helper, (*12)

How to run tests

$   cd tests
$   composer install
$   mkdir temp
$   ./vendor/bin/codecept build
$   ./vendor/bin/codecept run

The Versions

08/11 2017
02/11 2017

dev-simplified-use

dev-simplified-use

Facebook pixel for Nette

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

30/10 2017