Where is Facebook Code for Google Analytics?
Searching for a “Facebook code for Google Analytics” can feel like chasing a ghost, and in a way, you're right. There isn't a single piece of code you copy from Facebook and paste into Google Analytics to make them talk to each other. This article will show you the correct method, which is much more powerful: using tracking tags called UTM parameters. We'll walk you through exactly how to set them up so you can see the complete picture of your Facebook Ads performance right inside Google Analytics.
What’s the “Facebook Code” for Google Analytics? Let's Clarify
When you set up Google Analytics on your website, you embed a specific JavaScript code snippet (the GA tag) that tracks visitors. It’s natural to assume there’s a similar code for connecting third-party platforms like Facebook, but that’s not quite how it works for tracking ad campaigns.
The solution isn’t another piece of code, but an addition to your URLs. The "code" you're actually looking for is a set of UTM parameters. UTM stands for Urchin Tracking Module - a name left over from the company Google acquired to create Google Analytics. Think of them as simple tags you add to the end of your ad’s destination link. These tags act like tiny signposts, telling Google Analytics exactly how a visitor arrived on your site.
For example, instead of sending users to: https://www.yourstore.com/products/summer_dress
You’d send them to a URL that looks like this: https://www.yourstore.com/products/summer_dress?utm_source=facebook&utm_medium=cpc&utm_campaign=summer-launch-2024
That extra text at the end doesn't change the page a user lands on, but it carries valuable information that Google Analytics can read and organize.
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.
The 5 Types of UTM Parameters
There are five standard UTM parameters you can use. The first three are the most important and are often required by Google Analytics to properly attribute traffic.
- utm_source: This identifies where the traffic came from. For your Facebook ads, this will simply be facebook.
- utm_medium: This describes the marketing medium or channel. Common examples are cpc (cost-per-click), paid_social, email, or organic.
- utm_campaign: This identifies the specific campaign you are running, like summer-sale or q4-black-friday-deal.
- utm_content: This is used to differentiate ads within the same campaign. It's perfect for A/B testing. You could use it to label different ad creatives, like blue-video-ad vs. red-image-ad.
- utm_term: This is typically used for tracking paid keywords in search campaigns (like in Google Ads). It's less relevant for Facebook Ads but is available if you find a specific use case for it.
Why You Should Track Facebook Campaign Performance in Google Analytics
You might be wondering, "Why bother with all this? Doesn't Facebook Ads Manager already tell me how my ads are doing?" Yes, but it only tells you half the story.
Facebook Ads Manager is excellent at showing you platform-specific metrics like impressions, reach, link clicks, and post reactions. But its visibility ends the moment a user leaves Facebook. Google Analytics, on the other hand, tells you everything that happens after the click, providing a much richer understanding of your campaign's true impact.
Benefit 1: See the Full Customer Journey
Does traffic from your Facebook ads actually convert? Do those users browse more pages, or do they "bounce" immediately? Google Analytics answers these critical questions. By tracking events, goals, and e-commerce transactions, you can see if your highly-clicked ad is attracting curious browsers or serious buyers.
Benefit 2: Compare Marketing Channels Apples-to-Apples
Is Facebook pulling its weight compared to your other marketing efforts? In Google Analytics, you can line up traffic from facebook / cpc right next to google / organic and klaviyo / email. This unified view helps you make smarter budget allocation decisions based on which channels deliver the most engaged, high-converting users - not just clicks.
Benefit 3: Uncover Deeper Behavioral Insights
Your Facebook click report might be a sea of similar numbers, but Google Analytics can show you the nuances. Perhaps an ad with a lower click-through rate actually delivers visitors who spend twice as long on your site. You might discover that users coming from video ads browse more product pages than users from image ads. These insights are nearly impossible to find if you only look at your data within Facebook's platform.
Step-by-Step Guide: How to Track Facebook Ads in Google Analytics
Ready to get started? Setting this up is straightforward, especially since Facebook has a built-in tool that does most of the work for you. Let's walk through it.
Step 1: Decide on a Consistent Naming Convention
Before you build a single URL, take one minute to decide on your naming rules. Inconsistent UTM parameters are the number one cause of messy, unusable data in Google Analytics. For example, 'facebook,' 'Facebook,' and 'FB' will show up as three separate sources.
Here’s a simple, effective convention to follow:
- Use lowercase only. This avoids casing errors.
- Use dashes for spaces. Instead of "summer sale," use "summer-sale."
- Be descriptive but concise. Make your campaign names easy to understand at a glance.
Example convention template:
- utm_source: facebook
- utm_medium: paid_social (or cpc if you prefer)
- utm_campaign: Your actual campaign name in Ads Manager
- utm_content: a short description of the ad creative (e.g., video_testimonial_1)
Step 2: Create Your Tracking URLs
There are two primary ways to create your tracking URLs: manually with a URL builder or automatically within Facebook Ads Manager. The second option is almost always the better choice.
Method A: Manual with Google's URL Builder
If you're only running one or two ads or need a quick link for a one-off post, Google's Campaign URL Builder is a useful tool. You simply fill in the form with your website URL and your parameter values, and it generates the final tracking URL for you to copy and paste into the "Website URL" field of your ad.
This method works, but it’s tedious for managing multiple ads, prone to human error, and isn't scalable.
Method B: The Automated Way Using Dynamic Parameters in Facebook Ads Manager
This is the recommended approach for any serious advertiser. Facebook can automatically populate your UTM parameters with information directly from your campaign, ad set, and ad - saving you an enormous amount of time and preventing copy-paste errors.
Here’s how to set it up:
- Navigate to the Ad level within your campaign setup in Facebook Ads Manager (the level where you input your creative and copy).
- Scroll down to the "Tracking" section. You might need to click "See More" if it's hidden.
- Find the field labeled "URL Parameters." This is where the magic happens.
- Instead of typing out the static values, you're going to use Facebook's dynamic codes. Here is the best-practice setup to copy and paste directly into that "URL Parameters" box:
utm_source=facebook&utm_medium=paid_social&utm_campaign={{campaign.name}}&utm_adset={{adset.name}}&utm_ad={{ad.name}}
When your ad runs, Facebook will automatically replace the {{...}} placeholders with the actual names of your campaign, ad set, and ad. This ensures all your ads are tracked perfectly without you ever having to manually create a URL again.
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.
Where to Find Your Facebook Ads Data in Google Analytics
After your ads have been running for a day or so and generating clicks, your data will start appearing in Google Analytics. Here's where to find it.
Finding Your Data in Google Analytics 4
Google Analytics 4 is the current standard. Discovering your Facebook campaign data is simple.
- On the left-hand menu, go to Reports > Acquisition > Traffic acquisition.
- The default primary dimension in the table is "Session source / medium." You should see a row named facebook / paid_social (or whatever you set as your medium).
- To see individual campaign performance, click the small blue '+' icon next to the primary dimension dropdown and select "Traffic Source" and then "Session campaign." This adds a second column showing the campaign names that drove the traffic.
- You can do the same thing for "Session ad content" to view data based on the dynamic
{{ad.name}}parameter you set up. You can analyze your data using any engagement metrics available in GA to see which ads and campaigns bring you valuable website traffic and conversations.
Finding Your Data in Universal Analytics (UA)
If you're looking at historical data in the sunset version of Google Analytics, the path is slightly different.
- In the left-hand menu, navigate to Acquisition > All Traffic > Source/Medium. Here, you will see your "facebook / paid_social" traffic listed.
- Alternatively, go to Acquisition > Campaigns > All Campaigns. This report automatically uses the "Campaign" dimension as the primary focus, making it a quick way to see how each campaign is performing across goal completions and other metrics.
Final Thoughts
Ultimately, there is no magic "Facebook code for Google Analytics.” The solution lies in using UTM parameters - a simple yet powerful set of tags that bridge the gap between ad platforms and your website analytics. By implementing them correctly, you unlock a holistic view of your marketing, enabling you to understand not just what gets clicked, but what drives truly meaningful business results on your website.
Tired of bouncing between Facebook Ads Manager, Google Analytics, and a dozen other tabs just to see how your campaigns are performing? We know that feeling of manual reporting fatigue well, which is why we built Graphed. It allows you to connect all your marketing data sources in one place and instantly build real-time dashboards with simple, natural language - no more endless spreadsheets or trying to stitch together different platform views. You can finally just ask your questions and get clear, unified answers in seconds.
Related Articles
How to Create Facebook Ads API for Claude Code
Create a Meta Marketing API access token that never expires, using a system user, so Claude Code can pull Facebook ad reports and manage campaigns.
ClickHouse vs Postgres: When to Switch to Columnar
Comparing ClickHouse vs PostgreSQL means matching storage architecture to workload. Row storage wins for transactions. Columnar wins for scan-heavy analytics.
Google Ads for Orthodontists: Get More Booked Consults
Most orthodontic Google Ads campaigns waste money on low-intent searches. The problem is structure, not the platform.