Installing FB Pixel

How to Install a Facebook Pixel

September 08, 20246 min read

I'm exited to share with you what we do and how we can help you

Custom HTML/CSS/JAVASCRIPT

Introduction:

How to Install the Facebook Pixel on Your Website: A Step-by-Step Guide

If you're running a website and looking to optimize your marketing efforts, installing the Facebook Pixel is one of the most effective tools available. The Facebook Pixel allows you to track visitor activity on your site, retarget users with Facebook ads, and measure the success of your campaigns. This blog post will walk you through everything you need to know to set up and install the Facebook Pixel on your site.

What Is the Facebook Pixel?

The Facebook Pixel is a piece of code that you install on your website. It helps you track user activity, such as which pages they visit, what actions they take, and how they interact with your content. By collecting this data, you can optimize your Facebook ad campaigns, build custom audiences for retargeting, and better understand how people use your website.

In a nutshell, the Pixel helps you:

  • Track conversions from your Facebook ads.

  • Optimize your ad delivery.

  • Retarget website visitors.

  • Create lookalike audiences for future campaigns.

Step 1: Create a Facebook Pixel

  1. Log into Facebook Business Manager

    • First, you need to access your Facebook Business Manager account. If you don't have one, you'll need to create one here.

  2. Navigate to Events Manager

    • After logging in, find the Business Tools menu (represented by the 9 dots on the top left corner), and select Events Manager.

  3. Create a Pixel

    • In the Events Manager, select Connect Data Sources and then choose Web.

    • Click on Facebook Pixel and then hit Connect.

    • Give your Pixel a name that reflects your business or website (e.g., "YourWebsite Pixel"), and enter your website URL.

  4. Install the Pixel Code

    • Once you've created your Pixel, Facebook will give you the Pixel code. This is a snippet of JavaScript that you’ll need to install on your website. Copy this code; we’ll use it in the next steps.

Step 2: Install the Facebook Pixel on Your Website

There are different ways to install the Facebook Pixel on your site, depending on the platform you're using. Below are instructions for installing the Pixel manually or through popular platforms like WordPress, Shopify, and Google Tag Manager.

Option 1: Manual Installation (For Any Website)

  1. Access Your Website’s Code

    • You’ll need to paste the Pixel code into the header section of your website. If you're comfortable with code, open the HTML file of the pages where you want to track activity.

  2. Paste the Code in the Header

    • Find the <head> section of your website’s code. Paste the Pixel code right before the closing </head> tag. It should look like this:

    html

    Copier le code

    <head> <!-- Other head elements like title, meta tags --> <!-- Facebook Pixel Code --> <script> !function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window,document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', 'YOUR_PIXEL_ID'); fbq('track', 'PageView'); </script> <noscript> <img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=YOUR_PIXEL_ID&ev=PageView&noscript=1"/> </noscript> <!-- End Facebook Pixel Code --> </head>

  3. Save and Publish

    • Once the code is installed, save and upload your file to the web server.

Option 2: WordPress

  1. Install a Plugin

    • The easiest way to install the Facebook Pixel on WordPress is by using a plugin. You can use a plugin like Facebook for WordPress or PixelYourSite.

  2. Activate and Configure

    • After installing the plugin, activate it and enter your Facebook Pixel ID in the plugin settings. The Pixel ID is a unique identifier for your Pixel, which you can find in the Events Manager.

  3. Track Specific Events

    • If you're using a plugin, many of them allow you to track specific events (like "Add to Cart," "Purchase," or "Sign Up") without needing to modify your site's code.

Option 3: Shopify

  1. Access Shopify Admin

    • Log into your Shopify store, then go to Online Store > Preferences.

  2. Enter Facebook Pixel ID

    • Scroll down to the Facebook Pixel section and paste your Pixel ID in the field.

  3. Save Settings

    • Click Save and Shopify will automatically install the Pixel code on every page of your store.

Option 4: Google Tag Manager

  1. Create a New Tag

    • Log into your Google Tag Manager account and create a new tag. Choose the Custom HTML option.

  2. Add the Pixel Code

    • Paste the Facebook Pixel code (the JavaScript snippet) into the Custom HTML field.

  3. Configure Triggering

    • Set up the tag to fire on all pages, or on specific pages if you prefer.

  4. Publish the Tag

    • Save your changes and publish the tag in Google Tag Manager.

Step 3: Verify the Installation

  1. Use the Facebook Pixel Helper

    • To make sure your Pixel is working correctly, use the Facebook Pixel Helper Chrome extension. Install the extension from the Chrome Web Store and navigate to your website.

  2. Check for Pixel Firing

    • The Pixel Helper will tell you if the Pixel is firing and if it's installed properly. You should see information on the event that was triggered (e.g., PageView, AddToCart, etc.).

  3. Test Events in Events Manager

    • Go back to the Events Manager on Facebook and use the Test Events tool to simulate activity on your site. Enter your website URL, and Facebook will track whether the Pixel is firing when you perform specific actions.

Step 4: Set Up Custom Events and Conversions (Optional)

Once your Pixel is installed, you may want to track more specific actions on your website. These are called Custom Events.

  1. Create Custom Events

    • Custom events allow you to track actions like purchases, form submissions, or button clicks. You can create custom events by modifying the Pixel code and adding event parameters like this:

    javascript

    Copier le code

    fbq('track', 'Purchase', { value: 29.99, currency: 'USD' });

  2. Track Standard Events

    • Facebook provides a set of standard events you can use, such as "Purchase," "AddToCart," "Lead," and others. These can be implemented by modifying the Pixel code based on what specific actions you want to track.

  3. Set Up Custom Conversions

    • In the Events Manager, you can also set up custom conversions to define what counts as a successful action, such as a thank-you page view after a purchase.

Step 5: Optimize Your Ad Campaigns with Pixel Data

Now that the Facebook Pixel is collecting data from your website, you can use it to improve your Facebook ad campaigns. Here’s how:

  1. Create Custom Audiences

    • Use Pixel data to build custom audiences based on user behavior. For example, you can retarget users who have visited a product page but didn’t make a purchase.

  2. Optimize Ad Delivery

    • With the Pixel installed, Facebook can automatically optimize your ad delivery to people who are more likely to take the actions you want (like making a purchase or signing up for your newsletter).

  3. Lookalike Audiences

    • Create lookalike audiences to target people who have similar behavior to your existing customers.

  4. Measure Conversions

    • Monitor how your ads are performing and track conversions directly in the Events Manager.

Conclusion

Installing the Facebook Pixel is a powerful way to improve your website’s marketing performance. Whether you're looking to retarget visitors, track conversions, or optimize your Facebook ad spend, the Pixel gives you invaluable insights into how users interact with your website. By following the steps outlined in this guide, you’ll be able to easily install the Facebook Pixel and start making data-driven marketing decisions.

"If you encounter any trouble to set this up, don't hesitate to contact us for guidance"


Back to Blog