Where to Paste Google Analytics Code in Facebook?

Cody Schneider••8 min read

Thinking about how to get your Google Analytics tracking code to work inside Facebook? You're asking the right question, but the solution is a little different than you might expect. This guide will clear up the confusion and show you exactly how to track your Facebook Ads performance within Google Analytics, step-by-step.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

First, A Common Misconception

Let's address the main point of confusion right away: you don't actually paste your Google Analytics code anywhere inside Facebook's platform. It’s a common mix-up, so you're not alone in thinking this. Here’s why it works differently.

  • Your Google Analytics tracking code (the G-XXXXXXX tag or JavaScript snippet) belongs on your website. Its job is to watch visitors who arrive on your site and report on what they do.
  • Your Facebook Pixel (now called Meta Pixel) is Facebook’s tracking code. You guessed it - this also belongs on your website. Its job is to report back to Facebook on how visitors from its platform behave, which helps with ad optimization and conversion tracking.

Each platform uses its own code on your website to measure performance from its unique perspective. It’s like having two different reporters on the scene, each writing a story for their own newspaper.

So, if you can’t paste the Google code into Facebook, how do you tell Google Analytics which visitors came from your ads? You do it by giving each link in your Facebook Ad a special nametag. These "nametags" are called UTM parameters.

The Correct Way: Using UTM Parameters to Track Facebook Ads

UTM (Urchin Tracking Module) parameters are simple tags you add to the end of your website URL in your ads. When someone clicks on an ad link containing these tags, the information is sent directly to Google Analytics. This is how you tag arriving traffic so you know exactly which Facebook campaign, ad set, and specific ad it came from.

A basic URL with UTM tags looks something like this:

https://www.yourwebsite.com/?utm_source=facebook&utm_medium=cpc&utm_campaign=summer-sale-2024

Scared by the code? Don't be. Let's break down what each part does in plain English.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Understanding the 5 Core UTM Parameters

There are five standard UTM parameters, but for Facebook Ads, you'll mainly focus on the first three or four.

  • utm_source: Identifies where the traffic is coming from. For Facebook and Instagram ads, you’ll always set this to facebook or instagram. Example: utm_source=facebook
  • utm_medium: Identifies the marketing medium or channel. Common examples are cpc (cost-per-click), social, email, or affiliate. For paid ads, cpc is the standard. Example: utm_medium=cpc
  • utm_campaign: Identifies the specific campaign you are running. This should match the name you use inside Facebook Ads Manager. Example: utm_campaign=summer-sale-2024
  • utm_content: Use this to differentiate between ads within the same ad set. For example, you could describe the ad creative, like blue-video-ad versus red-image-ad. Example: utm_content=blue-video-ad
  • utm_term: This is typically used for tracking specific keywords in paid search campaigns (like Google Ads). It's rarely used for Facebook Ads, so you can generally ignore it.

How to Build and Add UTM Links to Your Facebook Ads

Now that you understand what UTMs are, let's get into the practical steps of building them and putting them in the right place within Facebook Ads Manager. You don’t need to be a developer to do this.

Step 1: Build Your UTM-Tagged URL

You can create these URLs yourself, but it's much easier - and safer - to use a tool that prevents errors. The most common one is Google's own Campaign URL Builder.

  1. Go to the GA4 Campaign URL Builder.
  2. Fill in the fields with your information:
  3. As you type, the tool will automatically generate your full URL at the bottom of the page. Copy this URL.

Step 2: Add the URL to Your Facebook Ad

This is it - the part where you "paste" your tracked link into Facebook. There's a specific box just for this inside Ads Manager.

  1. Open your campaign in Facebook Ads Manager and navigate to the Ad level (the last of the three levels: Campaign > Ad Set > Ad).
  2. Scroll down until you find the Destination section.
  3. Enter your base website link (without UTM parameters) in the Website URL field. For example: https://www.yourwebsite.com/sale.
  4. Now, look just below for a field called URL Parameters. This is where the magic happens.
  5. In this box, paste only the UTM parameter portion of the link you created. It's the string of text that starts with utm_source. It would look like this: utm_source=facebook&utm_medium=cpc&utm_campaign=summer-sale-2024
  6. You can also paste the full, UTM-tagged URL directly into the Website URL field, but using the specific URL Parameters box is considered best practice.

Once you’ve done this and published your ad, any traffic coming from that link will be neatly tagged and identifiable in your Google Analytics reports.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

A Pro-Tip: Use Dynamic Parameters to Automate Everything

Building unique UTMs for every single ad can become a major headache if you're running multiple campaigns. Thankfully, Facebook has a powerful feature called Dynamic URL Parameters that automates this process for you.

Instead of manually writing out your campaign name or ad name in the UTM Builder, you can use Facebook's dynamic placeholders. Facebook will automatically replace these placeholders with the actual names from your campaign setup.

Here’s what they look like:

  • {{campaign.name}}: Becomes your campaign's name.
  • {{adset.name}}: Becomes your ad set's name.
  • {{ad.name}}: Becomes your ad's name.
  • {{placement}}: Shows where the ad was displayed (e.g., Facebook_Feed, Instagram_Stories).

You can create a universal template and reuse it for all of your ads. Here's a powerful one you can copy and paste directly into the URL Parameters box for any ad:

utm_source=facebook&utm_medium=cpc&utm_campaign={{campaign.name}}&utm_adset={{adset.name}}&utm_ad={{ad.name}}

Simply paste this single line of code into the URL Parameters box, and you're set. Facebook will do the rest, automatically filling in the correct details for every ad. This method reduces human error and saves a massive amount of time.

How to See Your Facebook Ads Data in Google Analytics 4

Alright, you've set up your tracking. Now where do you find the data? You’ve put in the work, so let’s get to the payoff.

  1. Log into your Google Analytics 4 property.
  2. In the left-hand navigation menu, go to Reports > Acquisition > Traffic acquisition.
  3. The default view will show a table organized by Session default channel group. To see your UTM-tagged traffic, click the little drop-down arrow on that primary dimension.
  4. Select Session campaign to see data organized by the Campaign Name you set in your UTMs. You should see the names of your Facebook campaigns appear here.
  5. You can also add a secondary dimension by clicking the blue + icon next to the primary dimension header. Try adding Session source / medium or Session ad content for a more granular view.

If you see your campaign names appearing in these reports, congratulations! Your tracking is working perfectly.

Just remember that data from new campaigns can take anywhere from a few minutes to several hours to appear in GA4 reports. Don't worry if you don't see it immediately after an ad goes live.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

A Final Note: Why Facebook and Google Data Will Never Match Perfectly

You might notice that a campaign with 100 link clicks in Facebook Ads Manager only shows 85 sessions in Google Analytics. This is completely normal.

The two platforms use different attribution models and tracking methods. Facebook counts a "click" the moment a user clicks your ad, while Google Analytics only counts a "session" after the user's browser has fully loaded your website and the GA tracking code fires. A person might click your ad but close the window before your page loads, resulting in a click but not a session.

Don’t try to make them match 100%. Instead, use them together to get a complete picture. Facebook tells you how well your ads are performing on its platform, while Google Analytics tells you what those users did once they arrived on your website.

Final Thoughts

Tracking the performance of your Facebook campaigns in Google Analytics is a non-negotiable step for any serious marketer. While you don't paste Google's code directly into Facebook, using UTM parameters in your ad URLs lets you connect the dots, giving you a clear view of which campaigns truly drive traffic and conversions on your website.

Consolidating data from different sources like Facebook Ads and Google Analytics into one view can be a real time-sink, often involving endless hours spent in spreadsheets. At Graphed, we automate all of this. Within seconds of connecting your data sources, you can ask for dashboards in plain English. For instance, just ask, "Show me my Facebook Ad spend vs. website sessions and conversions from Google Analytics by campaign," and we'll build a live dashboard for you instantly, skipping all the manual work.

Related Articles