Giter Club home page Giter Club logo

laravel-facebook-pixel's Introduction

Facebook Pixel integration for Laravel

Latest Version on Packagist Software License Quality Score Total Downloads

An easy Facebook Pixel implementation for your Laravel application.

Facebook Pixel

The Facebook pixel is a snippet of JavaScript code that allows you to track visitor activity on your website. It works by loading a small library of functions which you can use whenever a site visitor takes an action (called an event) that you want to track (called a conversion). Tracked conversions appear in the Facebook Ads Manager and in the Facebook Analytics dashboard, where they can be used to measure the effectiveness of your ads, to define custom audiences for ad targeting, for dynamic ads campaigns, and to analyze that effectiveness of your website's conversion funnels.

For concrete examples of what you want to send throught the Standard Events

Install

You can install the package via Composer:

composer require weblagence/laravel-facebook-pixel

In Laravel 5.5 and up, the package will automatically register the service provider and facade

In L5.4 or below start by registering the package's the service provider and facade:

// config/app.php

'providers' => [
    ...
    WebLAgence\LaravelFacebookPixel\LaravelFacebookPixelServiceProvider::class,
],

'aliases' => [
    ...
    'LaravelFacebookPixel' => WebLAgence\LaravelFacebookPixel\LaravelFacebookPixelFacade::class,
],

Next, publish the config file:

php artisan vendor:publish --provider="WebLAgence\LaravelFacebookPixel\LaravelFacebookPixelServiceProvider"

Configuration

The configuration file is fairly simple.

return [

    /*
     * The Facebook Pixel id, should be a code that looks something like "XXXXXXXXXXXXXXXX".
     */
    'facebook_pixel_id' => '',
   
    /*
     * Use this variable instead of `facebook_pixel_id` if you need to use multiple facebook pixels
     */
    'facebook_pixel_ids' => [],
    
    /*
     * Enable or disable script rendering. Useful for local development.
     */
    'enabled'           => true,
];

Usage

Basic Example

First you'll need to include Facebook Pixel's script. Facebook's docs recommend doing this right after the body tag.

{{-- layout.blade.php --}}
<html>
  <head>
    @include('facebook-pixel::head')
    {{-- ... --}}
  </head>
  <body>
    @include('facebook-pixel::body')
    {{-- ... --}}
  </body>
</html>

Send pixel

At any moment, you can use the next function to create a Standard Event

\LaravelFacebookPixel::createEvent($eventName, $parameters = []);

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

laravel-facebook-pixel's People

Contributors

mmubasharsheikh avatar liepumartins avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.