Facebook Pixel and GA4 Setup for Shopify
Share
Facebook Pixel and GA4 Setup for Shopify (No Errors, No Apps) – 2025 Guide
📊 Why You Should Set Up Facebook Pixel and GA4 in Shopify (Without Apps)
As a Shopify store owner in 2025, tracking customer behavior is no longer optional—it’s essential. You need Facebook Pixel to run high-converting Meta Ads, and Google Analytics 4 (GA4) to analyze your full customer journey.
But what if you want to do it cleanly, without bulky third-party apps?
Here’s your 100% code-based guide to installing both Facebook Pixel and GA4 on your Shopify store without using any apps, ensuring accurate data tracking and faster site speed.
🛠 Prerequisites
-
Shopify admin access
-
Facebook Business Manager & Pixel ID
-
GA4 property created in Google Analytics
-
Basic understanding of Shopify theme files (we’ll guide you step-by-step)
✅ Step 1: Get Your Facebook Pixel ID
-
Go to your Meta Events Manager
-
Select your Pixel or create a new one
-
Copy the Pixel ID
✅ Step 2: Add Facebook Pixel to Shopify Without App
🔧 Method: Insert code into theme.liquid
-
In Shopify Admin, go to:
Online Store > Themes > Edit Code -
Open
theme.liquid
-
Paste the following code just above the closing
</head>
tag:
<!-- Facebook 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"
src="https://www.facebook.com/tr?id=YOUR_PIXEL_ID_HERE&ev=PageView&noscript=1"/>
</noscript>
<!-- End Facebook Pixel Code -->
🔁 Replace YOUR_PIXEL_ID_HERE
with your actual Facebook Pixel ID.
✅ Bonus: Track Add to Cart, Purchase & More
To track Purchase Events without apps:
-
Open:
checkout > thank_you.liquid
-
Paste this at the bottom of the file:
<script>
fbq('track', 'Purchase', {
value: {{ checkout.total_price | money_without_currency }},
currency: '{{ checkout.currency }}'
});
</script>
Repeat similar logic for AddToCart, ViewContent, or InitiateCheckout in their respective templates.
✅ Step 3: Get Your GA4 Measurement ID
-
Go to Google Analytics
-
Create a GA4 property
-
Click on Admin > Data Streams > Web
-
Copy your Measurement ID (looks like
G-XXXXXXX
)
✅ Step 4: Add GA4 to Shopify Without App
-
In Shopify Admin, go to:
Online Store > Themes > Edit Code -
Open
theme.liquid
-
Paste this above the
</head>
tag (below Facebook Pixel):
<!-- Google Analytics 4 (GA4) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXX');
</script>
🔁 Replace G-XXXXXXX
with your actual GA4 ID.
🔄 Track Purchases in GA4 Without App
To manually send purchase events to GA4:
-
Open:
checkout > thank_you.liquid
-
Paste this code:
<script>
gtag('event', 'purchase', {
transaction_id: '{{ checkout.order_number }}',
value: {{ checkout.total_price | money_without_currency }},
currency: '{{ checkout.currency }}',
items: [
{% for line_item in checkout.line_items %}
{
item_name: '{{ line_item.title }}',
quantity: {{ line_item.quantity }},
price: {{ line_item.final_line_price | money_without_currency }}
},
{% endfor %}
]
});
</script>
This ensures accurate GA4 eCommerce tracking for your Shopify store—without any apps!
🧪 Step 5: Verify Your Tracking
-
Use the Meta Pixel Helper Chrome Extension to test Facebook Pixel
-
Use Google Tag Assistant or GA4 DebugView in your Analytics dashboard
-
Confirm events like
Purchase
,PageView
,AddToCart
are triggering correctly
⚠️ Pro Tips to Avoid Tracking Errors
-
Always double-check for typos or missing tags
-
Never install multiple tracking apps alongside this code (will cause duplicates)
-
Backup your theme before editing liquid files
-
Use Shopify Plus's server-side tagging if you’re scaling (optional advanced setup)
🎯 Final Thoughts
Setting up Facebook Pixel and GA4 in Shopify without apps is not only possible—it’s the smartest way to:
-
Improve site speed
-
Avoid app conflicts
-
Maintain full control over your tracking
By following this guide, you’ll have a clean and powerful analytics setup for your Shopify store that helps you run profitable ad campaigns and make data-driven decisions in 2025.
Need help with tracking setup, event mapping, or advanced conversion APIs?
At RootSyntax, we offer Shopify performance and analytics setup services tailored to your store. Book a free consultation today.