Adding a Facebook pixel to your online store

You can integrate a Facebook pixel with your online store to help you understand customer behavior and traffic. A Facebook pixel collects data about how customers are using your online store pages, so that you can more effectively plan your ad campaigns to find new customers.

Before you add a Facebook pixel to your store, you can learn more about the Facebook pixel at the Facebook Help Center.

Before you begin

Before you can add a Facebook pixel to your online store, you need to have a Facebook ads account and you need to set up the pixel in Facebook Ads Manager. If you've used a Facebook pixel with your online store in the past and you want to create a new pixel, then you might need to remove Facebook pixel code from your online store first.

Creating a Facebook ads account

Before you can create a Facebook pixel, you need a Facebook Ads Manager account. To create an account, go to Facebook.

Step-by-step instructions from the Facebook Help Center

You can find step-by-step instructions for using the Facebook pixel with Shopify at the Facebook Help Center.

Remove Facebook pixel code from your online store

If you've used a Facebook pixel with your online store in the past, you might need to remove its code in Shopify before adding a new pixel. Adding a second Facebook pixel to your online store could cause duplicate or incorrect data in your reports.

You might have added the code for a Facebook pixel in your store files, such as the theme.liquid file. Remove any existing Facebook pixel code from all of your store files before you create a new Facebook pixel.

Remove pixel code from your theme file

If you've added the Facebook pixel to your online store by editing your store's theme in Shopify, then you can remove the existing pixel code from your theme.liquid file.

Steps:

  1. In the Current theme section, click Actions, and select Edit code.
  2. Click the theme.liquid file to open the code editor.
  3. Delete the Facebook pixel code. You can find it between the <head> and </head> tags.
  4. Click Save.

Creating a Facebook pixel

You can create a Facebook pixel in Facebook Ads Manager. For the steps on creating a Facebook pixel, go to the Facebook Help Center.

Add a Facebook pixel ID to your online store preferences

You can add a Facebook pixel ID to your online store preferences in Shopify to integrate the pixel with your online store. Using this integration doesn't require you to edit your online store code. Instead, you'll enter the Facebook pixel ID.

Steps:

  1. In Facebook Ads Manager, click the Ads Manager drop-down menu, and then select Pixels to view your pixels.
  2. Copy the pixel ID for the pixel that you want to integrate with your online store. The pixel ID is shown under the name of the pixel.
  3. From your Shopify admin, go to Online Store > Preferences.

  4. In the Facebook Pixel section, add the pixel ID:

    • If you're adding a pixel for the first time, then enter the Facebook pixel ID:  
    • If you're changing to a new Facebook pixel from an existing one, then click Change before entering the new Facebook pixel ID.
  5. Click Save.

After you add the pixel to your online store, then you can make sure that it's working by using Facebook Ads Manager. Learn about how to tell if your Facebook pixel is working from the Facebook Help Center.

Facebook pixel standard events

When an action happens on your online store after you've added a Facebook pixel in Shopify, the pixel counts the action as an event. You can use event data to learn more about how customers interact with your store. Learn more about using Facebook pixel standard events to create campaigns and track conversions at the Facebook Help Center.

After you integrate a Facebook pixel with your online store, it automatically tracks 9 standard events:

Event name Event description
ViewContent When a visitor views a page, for example a product page
Search When a visitor makes a search
AddToCart When a visitor adds a product to the shopping cart
AddToWishlist When a visitor adds a product to a wishlist
InitiateCheckout When a visitor clicks on the checkout button
AddPaymentInfo When a visitor enters payment information in the checkout
Purchase When a customer completes a purchase and views the thank you page in the checkout
Lead When a visitor clicks a sign up, for example a click to signup for a trial
CompleteRegistration When a visitor completes a registration form, for example a signup for a service

Ready to start selling with Shopify?

Try it free