How to Get Instagram Ad Code

Cody Schneider8 min read

Looking for your "Instagram ad code" to track campaign performance is a smart move, but you won't find it inside the Instagram app. The code you need is actually the Meta Pixel, and it's the key to unlocking powerful ad optimization and tracking across both Instagram and Facebook. This article will guide you through exactly what this code is, why it’s so important, and how to get it set up on your website step-by-step.

What is the "Instagram Ad Code," Really?

First, let's clear up some common confusion. There isn’t a separate tracking code just for Instagram ads. Instead, Meta (the parent company of Instagram and Facebook) uses a single, universal piece of code called the Meta Pixel to track and measure ad performance across all its platforms.

The Meta Pixel is a small snippet of JavaScript that you install on your website. Once it's in place, it acts as a connection between your ads and your website activity. It tracks the actions visitors take after clicking your Instagram ad, such as viewing a product, adding an item to their cart, or making a purchase.

You’ll manage and retrieve this code not from the Instagram app, but from the Meta Events Manager within your Meta Business Suite. Think of it as the central hub for all your off-app tracking data.

Why You Absolutely Need the Meta Pixel for Instagram Ads

Running Instagram ads without the Meta Pixel is like driving with your eyes closed - you're spending money but have no real idea where you're going or what's working. Installing this little piece of code is one of the most important things you can do to improve your ad performance. Here’s why:

  • Track Conversions & Prove ROI: The pixel’s primary job is to measure conversions. It tells you exactly how many people completed a specific action on your site (like a purchase or lead form submission) after seeing your ad. This data is critical for calculating your campaign's Return on Ad Spend (ROAS) and proving that your marketing budget is generating real results.
  • Optimize Your Ads for Better Results: When the pixel sends conversion data back to Meta, it feeds the powerful ad delivery algorithm. Meta learns the characteristics of people who convert on your site and then actively seeks out similar people in its user base to show your ads to. This leads to more efficient ad spend and a lower cost per result over time.
  • Create Powerful Retargeting Audiences: Have you ever visited a website and then seen ads for that exact product follow you around on Instagram? That’s the Meta Pixel at work. You can create highly effective Custom Audiences based on user behavior, such as targeting everyone who added an item to their cart but didn’t complete the purchase in the last 14 days. This allows you to re-engage warm audiences with targeted messaging.
  • Build High-Quality Lookalike Audiences: Once the pixel has gathered enough data on your converters (e.g., 100 people who made a purchase), you can create what's called a Lookalike Audience. Meta analyzes the common traits of your existing customers and finds new people who share those characteristics. It's one of the most effective ways to find new, high-intent customers at scale.

Step-by-Step Guide: How to Get Your Meta Pixel Code

Ready to get your hands on the code? The process is straightforward and happens entirely within Meta's platform. Follow these steps to create and find your pixel.

Step 1: Navigate to Meta Events Manager

Your journey begins in Meta Events Manager, the command center for your pixel. You can access it directly by going to business.facebook.com/events_manager. Make sure you are logged into the correct Meta Business Account that you use to run your ads.

Step 2: Connect a New Data Source

Once you’re in Events Manager, look for a green plus icon or a button that says "Connect Data Sources" on the left-hand menu. Click it to begin the setup process. This is where you tell Meta what you want to track.

Step 3: Select 'Web' as Your Data Source

You'll see a few options like Web, App, Offline, and CRM. Since the goal is to track activity on your website, you’ll want to select Web. Click "Connect" to proceed.

Step 4: Name Your Pixel

Give your pixel a name. This is purely for your own reference, so make it something you’ll easily recognize. A good practice is to use your business or website name, such as "[Your Business Name] Pixel." After naming it, click "Create Pixel."

Step 5: Add a Website and Choose an Installation Method

Meta will ask for your website URL. Enter it, and it will check to see if you're using a common platform like Shopify or WordPress that offers a "partner integration" for an easier setup.

Next, you’ll be asked how you want to install the pixel code. You have two main options:

  1. Manually install code: This involves copying the full pixel code and pasting it into your website's header. It's a good option if you have a custom-built website or are comfortable with code.
  2. Use a partner integration: This is the recommended and easiest method for most users. Meta has partnerships with dozens of platforms (Shopify, WordPress, Wix, etc.) that simplify the installation down to just copying and pasting your Pixel ID number.

Select your preferred method. For most users, "Use a partner integration" is the best path forward.

Step 6: Retrieve Your Pixel Code or ID

If you chose "Manually install code"...

You'll be presented with the full JavaScript code snippet. It will look something like this:

<!-- Meta 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-HERE'),
fbq('track', 'PageView'),
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=YOUR-PIXEL-ID-HERE&ev=PageView"
/></noscript>
<!-- End Meta Pixel Code -->

Your task is to copy this entire code block and paste it into the <head> section of your website’s HTML. This ensures it loads on every single page.

If you chose "Use a partner integration"...

This is where things get much simpler. Instead of copying the whole code, you just need your Pixel ID. Back in Events Manager, you can find this ID under your pixel's name in Data Sources, or in the Settings tab for the pixel itself. It's a long string of numbers (e.g., 1234567890123456).

Copy this ID – this is all you will need for most platform integrations.

How to Install the Pixel on Popular Platforms

Here’s how to quickly install your pixel using the Pixel ID on a few of the most common platforms.

Installing on Shopify

Shopify makes pixel installation incredibly easy.

  1. From your Shopify Admin dashboard, go to Online Store > Preferences.
  2. Scroll down to the Meta Pixel section. You might see it labeled as "Facebook Pixel" if Shopify hasn't updated the text yet.
  3. Paste your Pixel ID into the box and click save.

That's it! Shopify automatically integrates the pixel and even sets up key e-commerce events like ViewContent, AddToCart, and Purchase for you.

Installing on WordPress

For WordPress, the easiest way is to use a plugin.

  1. From your WordPress dashboard, go to Plugins > Add New.
  2. Search for Meta's official plugin, "Meta Pixel for WordPress," or a popular alternative like "PixelYourSite."
  3. Install and activate the plugin you choose.
  4. Navigate to the plugin’s settings page, where you will find a field to paste your Pixel ID.
  5. Save your changes.

Using Google Tag Manager (GTM)

If you're already using GTM to manage your marketing tags, adding the Meta Pixel is a breeze.

  1. In GTM, create a new Tag. Give it a name like "Meta Pixel - Base Code."
  2. For Tag Configuration, search the Community Template Gallery for "Facebook Pixel" and choose the one by 'facebookarchive'.
  3. Paste your Pixel ID into the required field. For the event, leave it as the standard "PageView."
  4. Under Triggering, select "All Pages." This ensures the pixel fires on every page of your site.
  5. Save and publish your changes in GTM.

GTM gives you more granular control for setting up custom event tracking later on.

Verifying Your Pixel is Working

After you’ve installed the code, you need to make sure it's working properly before you start running ads.

First, install the Meta Pixel Helper, a free Chrome extension provided by Meta. Once added to your browser, navigate to your website. If the pixel is set up correctly, the extension's icon will light up blue and show you which events (like PageView) have fired successfully on that page. If it shows an error, it will provide tips for fixing it.

You should also head back to the Meta Events Manager. After a few minutes of activity on your site, you should see the status of your pixel change to "Active" and data will begin to appear in the overview tab.

Final Thoughts

So, the "Instagram ad code" is really the powerful and essential Meta Pixel that works across all of Meta's platforms. By installing it on your website, you transform your advertising from a guessing game into a data-driven strategy, enabling precise conversion tracking, ad optimization, and audience creation.

Once your pixel is firing and data from your ads, website, and sales platforms is flowing, the next big step is to make sense of it all. At Graphed, we help you simplify this process by connecting all these disparate data sources - like Meta Ads, Google Analytics, Shopify, and more - into one unified view. We've made it possible to build real-time dashboards and get answers from your data using simple, conversational language, helping you see the full journey from ad click to final sale. To experience a smarter, faster way to analyze your performance, you can try Graphed for yourself.

Related Articles

How to Connect Facebook to Google Data Studio: The Complete Guide for 2026

Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.

Appsflyer vs Mixpanel​: Complete 2026 Comparison Guide

The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.