Tracking your store’s performance is essential for growing your Shopify business. By integrating Google Analytics, Google Search Console, and Facebook Pixel, you can gather valuable insights into your website traffic, customer behavior, and ad performance.
Additionally, if you run ads or track conversions, you may need to place custom event scripts like purchase conversions, add-to-cart tracking, and lead generation codes.
In this guide, we will cover:
- How to connect Google Analytics 4 (GA4) to Shopify
- How to set up Google Search Console for Shopify
- How to install Facebook Pixel on Shopify
- Where to copy and paste custom event scripts for tracking conversions
1. How to Connect Google Analytics 4 to Shopify
Google Analytics helps track visitor behavior, traffic sources, and e-commerce performance. Shopify no longer supports Universal Analytics, so you must use Google Analytics 4 (GA4).
Step 1: Create a Google Analytics Account
- Go to Google Analytics and sign in.
- Click "Admin" (bottom left corner).
- Under "Account", click "Create Account", name your account, and click Next.
- Under "Property", enter your store name and select your time zone and currency.
- Choose "Web" as your platform and enter your Shopify store’s URL.
- Click "Create" and accept the terms.
Step 2: Get Your Google Analytics 4 Measurement ID
- In your GA4 property, go to Admin > Data Streams.
- Select your website and copy the Measurement ID (it starts with "G-").
Step 3: Add GA4 to Shopify
- Log in to your Shopify admin panel.
- Go to Settings > Customer events.
- Click Add custom event and paste your GA4 Measurement ID.
- Click Save and enable enhanced e-commerce tracking.
Your Shopify store is now connected to Google Analytics 4, and data will start tracking in your GA4 dashboard.
2. How to Set Up Google Search Console for Shopify
Google Search Console (GSC) helps track your website’s performance in Google Search, monitor indexing issues, and improve SEO rankings.
Step 1: Create a Google Search Console Account
- Go to Google Search Console and log in with your Google account.
- Click "Add Property" and select "Domain".
- Enter your Shopify store’s domain (without "https://" or "www").
- Click Continue.
Step 2: Verify Your Shopify Store
Google will ask you to verify ownership of your website. Follow these steps:
-
Select "DNS verification" as the method.
- Copy the TXT record provided by Google.
- Log in to your domain provider’s dashboard (e.g., GoDaddy, Namecheap).
- Navigate to DNS settings and add the TXT record.
- Save the record and go back to Google Search Console.
- Click "Verify" (it may take a few hours to update).
Once verified, Google will start collecting search data for your Shopify store.
3. How to Install Facebook Pixel on Shopify
Facebook Pixel helps track visitor interactions, optimize ads, and measure conversions from Facebook and Instagram campaigns.
Step 1: Create a Facebook Pixel
- Go to Meta Business Manager and sign in.
- Click "Events Manager" in the left menu.
- Click "Connect Data Sources" > "Web" > Facebook Pixel.
- Enter a name for your Pixel and click Continue.
- Click "Set up manually" and copy the Pixel ID.
Step 2: Add Facebook Pixel to Shopify
- In Shopify admin, go to Settings > Customer Events.
- Click Add a custom event.
- Paste your Facebook Pixel ID and click Save.
- Go back to Facebook Events Manager, click Test Events, and visit your Shopify store to see if data is being received.
Facebook will now track visitor behavior and conversions on your Shopify store.
4. Where to Copy Custom Event Scripts in Shopify
If you need to track specific custom events like purchase conversions, add-to-cart actions, or form submissions, you must place the tracking scripts in the right sections of your Shopify store.
A. Adding Conversion Tracking to the Thank You Page
To track a purchase event after checkout:
- In Shopify Admin, go to Settings > Checkout.
- Scroll to Order status page.
- Paste the custom conversion tracking script in the Additional scripts box.
- Click Save.
Example of a Facebook Purchase Event Script:
This script tells Facebook that a customer completed a purchase worth $50.00 USD.
B. Adding Event Tracking to Product Pages
To track "Add to Cart" events:
- Go to Online Store > Themes > Edit Code.
- Open theme.liquid and locate the Add to Cart button code.
- Insert the event tracking script inside the button’s
onclick
attribute.
Example of an "Add to Cart" Event Script for Facebook Pixel:
C. Adding Event Tracking to the Header (Site-Wide Tracking)
If you need to track general visitor behavior, place scripts in the theme.liquid file:
- In Shopify admin, go to Online Store > Themes > Actions > Edit Code.
- Open theme.liquid.
- Find the
<head>
section and paste your script inside it.
- Click Save.
Example of a Google Analytics Custom Event Tracking Script:
This script tracks page views across your store.
Setting up Google Analytics, Google Search Console, and Facebook Pixel is crucial for tracking visitor behavior, improving SEO, and optimizing ad performance. Additionally, placing custom event scripts in the right sections of your Shopify store allows you to track specific actions like purchases, add-to-cart events, and leads.
By following this guide, you can ensure your Shopify store is properly connected to essential analytics and marketing tools, allowing you to make data-driven decisions and maximize conversions.