askvity

How to Install Facebook Pixel Code on Shopify?

Published in Shopify Marketing Setup 4 mins read

Installing the Facebook Pixel code on your Shopify store allows you to track website visitors' actions, measure the effectiveness of your Facebook ads, and build audiences for retargeting. The most common manual method involves copying the code from your Facebook Business Manager and pasting it into your Shopify theme files.

Here's how to manually install the Facebook Pixel code on Shopify:

Getting Your Facebook Pixel Code

The first step is to access and copy the unique code snippet for your Facebook Pixel.

  1. Go to your Facebook Business Manager account. Navigate to your account where your pixels are managed.
  2. Click on Events Manager. This is where you manage your data sources, including pixels.
  3. Select the pixel you want to use. Choose the specific pixel you intend to install on your Shopify store.
  4. Click on Settings. This section contains the details and installation options for your pixel.
  5. Locate and copy the code. The reference indicates, "The code will appear, you copy the Facebook pixel code from the Install Pixel section." You are looking for the base pixel code, which typically starts with <!-- Facebook Pixel Code -->.

Installing the Code on Shopify

Once you have the pixel code copied, you need to add it to your Shopify store's theme.

  1. Go to your Shopify store's admin panel. Log in to your Shopify account dashboard.
  2. Click on Themes. This is usually found under 'Online Store' in the navigation menu.
  3. Edit your theme code. Find the theme you want to edit (likely your current live theme), click the ... button next to 'Customize', and select 'Edit code'.
  4. Locate theme.liquid: In the 'Layout' directory, click on theme.liquid. This file controls the basic structure of all pages on your store.
  5. Paste the Pixel code: Paste the entire Facebook Pixel code you copied directly before the closing </head> tag. This ensures the pixel fires on every page load.
  6. Save your changes: Click the 'Save' button in the top right corner.

Your Facebook Pixel should now be installed and active on your Shopify store. You can verify its installation using the Facebook Pixel Helper browser extension.

Alternative Installation Method: Shopify's Facebook Sales Channel

Shopify also offers a more integrated method through the official Facebook & Instagram channel app. This is often the recommended approach as it handles standard events automatically without requiring code edits.

  1. Install the Facebook & Instagram channel app from the Shopify App Store.
  2. Connect your Facebook account and Business Manager.
  3. Select your desired Facebook Pixel from the options provided.
  4. Follow the setup prompts to enable data sharing and event tracking.

This method integrates directly with Shopify's checkout process and standard events (like View Content, Add to Cart, Initiate Checkout, Purchase) are tracked automatically.

Manual vs. Integrated Installation

Here's a quick comparison:

Feature Manual Code Installation Shopify Sales Channel Integration
Ease of Setup Requires finding/editing theme code App-based, no code editing required
Event Tracking Requires adding code for standard/custom events Automatically tracks standard events
Flexibility Full control over code placement and custom events Limited to app's built-in functionality
Maintenance May require re-installation if theme is updated Handles updates automatically through the app

While manual installation gives you fine-grained control, using the official Shopify integration via the Sales Channel is often simpler and more reliable for most standard tracking needs.

Related Articles