This article will guide you through setting up your Facebook Pixel on Magento 2.

This article will cover how to add the Facebook Pixel to all pages and to the order success page for conversions.

Step 1: Adding Facebook Pixel to All Pages

  1. In the Magento Admin Panel, go to to Content > Design > Configuration
    41812258.png
  2. In the configuration record corresponding to your store view, click Edit.
  3. Go to Other Settings > HTML Head > Scripts and Style Sheets.
    Scripts.png
  4. Copy and paste the Facebook Pixel into the area next to Scripts and Style Sheets.
  5. In the upper right hand corner, press Save Configuration.
  6. Clear cache.

Step 2: Setting Up Facebook Pixel on Order Success Page

  1. Login to your Magento Admin Panel.
  2. Go to Content > Blocks.
    1. 41812256.png
  3. This will bring you to the Blocks page. Click on Add New Block:
    1. 41812255.png
  4. You should now be on the following page:
    1. 41812254.png
      1. Enable Block - Leave this setting as Yes
      2. Block Title - Enter "Facebook Pixel"
      3. Identifier - Enter facebook_pixel
      4. Store View - By default, this should be selected as All Store Views. If it is not, click All Store Views.
      5. Text Area - Add the pixel here.
  5. Once you have configured the settings in Step 4, press Save in the upper right hand corner.

Step 2: Creating the Widget

  1. Go to Content > Widgets.
    1. 41812253.png
  2. Click Add Widget.
    1. 41812252.png
  3. Change the Type to CMS Static Block.
    1. 41812250.png
  4. Change Design Theme to Smartwave Porto CPC.
    1. 41812249.png
  5. Press Continue
  6. You should now see the following form:
    1. 41812248.png
      1. Set the Widget Title to Facebook Pixel.
      2. Next to Assign to Store Views, click All Store Views.
      3. You can leave Sort Order blank.
  7. Click Add Layout Update.
    1. Change Display On to Specified Page.
      1. 41812247.png
    2. Change Page to One Page Checkout Success.
  8. Set Container to Main Content Top. 
    1. 41812245.png
  9. On the left under Widget, click Widget Options.
    1. 41812243.png
  10. Click Select Block.
    1. 41812242.png
  11. Choose the block with the ID facbook_pixel.
  12. Press Save.