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 ad 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 have a Facebook pixel ID added to your online store preferences, then you can replace the it with a new pixel ID that you create in Facebook.

If you edited your theme code to add the Facebook pixel, then you need to remove the pixel code before you can add a Facebook pixel ID in your online store preferences. Otherwise, your store will have more than one pixel on it, which could result in duplicate or incorrect data in your reports.

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 in your online store preferences. Find detailed instructions for connecting your Shopify account to Facebook from Facebook Advertiser Help.

Steps:

  1. From your Shopify admin, go to Online Store > Preferences.

  2. In the Facebook Pixel section, add your Facebook 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.
  3. 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

After you've added a Facebook pixel in Shopify, the pixel tracks certain events on your online store. 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.

Events that track a value use an order's subtotal, which doesn't include taxes or shipping costs.

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

Facebook pixel standard event descriptions
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
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

Ready to start selling with Shopify?

Try it free