Mastering Your Data: How to Set Up Google Analytics 4 (GA4) with Google Tag Manager on WordPress

Understanding how visitors interact with your website is crucial for growth, whether you’re running a small blog or a bustling e-commerce store. Google Analytics 4 (GA4) is Google’s latest analytics platform, offering powerful insights into user behavior across different devices. While setting it up directly can be done, integrating it via Google Tag Manager (GTM)…

Understanding how visitors interact with your website is crucial for growth, whether you’re running a small blog or a bustling e-commerce store. Google Analytics 4 (GA4) is Google’s latest analytics platform, offering powerful insights into user behavior across different devices. While setting it up directly can be done, integrating it via Google Tag Manager (GTM) provides unparalleled flexibility, control, and efficiency for managing all your website’s tracking codes.

This detailed tutorial will walk you through the precise steps to connect GA4 to your WordPress site using Google Tag Manager, empowering you to gather essential data and make informed decisions.

Why GA4 and Google Tag Manager?

  • Google Analytics 4 (GA4): Focuses on “events” rather than traditional “sessions,” giving you a more holistic, user-centric view of engagement. It’s built for the future, offering cross-platform tracking and predictive capabilities. Universal Analytics (GA3) is being sunsetted, making GA4 an essential upgrade.
  • Google Tag Manager (GTM): Acts as a central hub for all your website tags (like GA4, Facebook Pixel, LinkedIn Insight Tag, etc.). Instead of manually adding code snippets to your WordPress theme files, you place one GTM container code, and then manage all other tags within the GTM interface. This simplifies tag deployment, reduces reliance on developers, and significantly speeds up testing and updates.

What You’ll Need

Before we dive in, ensure you have the following:

  • A Google Account: Essential for accessing Google Analytics and Google Tag Manager.
  • Administrator Access to Your WordPress Site: You’ll need to install a plugin and potentially verify GTM installation.
  • Your Website’s URL: Ready to be entered into Google Analytics and Tag Manager.
  • Basic Internet Navigation Skills: The process involves moving between different Google services and your WordPress dashboard.

Let’s get started!

Step 1: Create Your Google Analytics 4 Property

First, we need a GA4 property to send data to.

  1. Go to Google Analytics: Open your web browser and navigate to analytics.google.com. If you’re new to Google Analytics, you’ll be prompted to start setup. If you have existing properties, you’ll be taken to your Analytics homepage.
  2. Create a New Property:
  • Click on Admin (the gear icon) in the bottom left corner.
  • In the “Property” column, click Create Property.
  1. Property Setup:
  • Property Name: Give your property a clear, descriptive name (e.g., “My Website GA4 Property”).
  • Reporting Time Zone: Select your business’s time zone.
  • Currency: Select your local currency.
  • Click Next.
  1. Business Information (Optional but Recommended): Fill out your industry category, business size, and how you intend to use Google Analytics. This helps Google tailor future insights. Click Create.
  2. Set Up a Data Stream: Once your property is created, you’ll be prompted to choose a data stream. This is where your data will come from.
  • Select Web.
  • Website URL: Enter your full website URL (e.g., ZEALTERCODE0).
  • Stream Name: Give your stream a name (e.g., “My Website Web Stream”).
  • Enhanced measurement: This option is enabled by default and tracks common user interactions like page views, scrolls, outbound clicks, site search, video engagement, and file downloads. It’s highly recommended to leave this on for robust initial tracking.
  • Click Create stream.
  1. Note Your Measurement ID: After creating the stream, you’ll see a screen with your stream details. Crucially, locate the Measurement ID, which will look like ZEALTERCODE0. Copy this ID and keep it handy – we’ll need it for Google Tag Manager.
  • Pro Tip: If you ever need to find your Measurement ID again, go to ZEALTERCODE0.

Step 2: Set Up Your Google Tag Manager Account & Container

Now, let’s create a Google Tag Manager account and container for your WordPress site.

  1. Go to Google Tag Manager: Open your web browser and navigate to tagmanager.google.com.
  2. Create Account:
  • If you’re new, click Create Account.
  • Account Setup:
  • Account Name: Enter a name for your GTM account (e.g., “My Business Name”).
  • Country: Select your country.
  • Container Setup:
  • Container Name: Enter your website’s URL (e.g., “yourwebsite.com”).
  • Target Platform: Select Web.
  • Click Create.
  1. Accept Terms of Service: Read and accept the Google Tag Manager Terms of Service Agreement.
  2. GTM Installation Code: Immediately after creation, a pop-up window will appear showing two code snippets – one for the ZEALTERCODE0 section and one for immediately after the opening ZEALTERCODE1 tag. Keep this window open or copy these snippets to a text file. We’ll install these on your WordPress site in the next step.
  • Note: The GTM container is now created. You’ll see its ID (e.g., ZEALTERCODE0) in the top right corner of the GTM interface.

Step 3: Install Google Tag Manager on WordPress (Using Site Kit by Google)

The easiest and most reliable way to integrate GTM with WordPress is by using an official plugin like “Site Kit by Google.” This method avoids manual code editing, which can be risky for beginners.

  1. Log in to Your WordPress Dashboard: Go to ZEALTERCODE0.
  2. Install Site Kit by Google:
  • From your WordPress Dashboard, navigate to Plugins > Add New.
  • In the search bar, type “Site Kit by Google” and press Enter.
  • Locate the “Site Kit by Google” plugin (usually the first result, by Google).
  • Click Install Now, then Activate.
  1. Start Site Kit Setup:
  • Once activated, you’ll see a prompt to “Start Setup” for Site Kit. Click it.
  • You’ll be redirected to Google to sign in with the Google Account you used for GA4 and GTM.
  • Grant Site Kit the necessary permissions (view and manage data for Google Analytics, Search Console, etc.).
  • Follow the on-screen prompts to complete the initial setup. Site Kit will automatically connect to your Google Search Console.
  1. Connect Google Tag Manager:
  • Once Site Kit is active and connected, go to your WordPress Dashboard.
  • Navigate to Site Kit > Settings.
  • Click on the Connect More Services tab.
  • Find “Tag Manager” and click Connect Service.
  • You’ll be prompted to sign in with your Google Account again if necessary.
  • Site Kit will then ask you to select the Google Tag Manager account and container you created in Step 2 from a dropdown menu. Choose the correct ones.
  • Click Configure Tag Manager or Confirm (the exact wording may vary slightly).
  • Site Kit will now automatically inject the GTM code snippets into the correct locations on your WordPress site.
  • Manual (Advanced) Alternative: If you prefer not to use Site Kit or any plugin, you would manually paste the GTM ZEALTERCODE0 snippet into your theme’s ZEALTERCODE1 file (just after ZEALTERCODE2) and the ZEALTERCODE3 snippet into ZEALTERCODE4 or ZEALTERCODE5 (immediately after ZEALTERCODE6). This requires caution, knowledge of child themes to prevent updates from overwriting your changes, and should only be done by experienced users. For this tutorial, we focus on the plugin method.

Step 4: Configure Google Analytics 4 in Google Tag Manager

Now that GTM is on your WordPress site, we need to tell GTM to fire your GA4 tag.

  1. Go to Google Tag Manager: Open tagmanager.google.com and select your website’s container.
  2. Create a New Tag:
  • In the left-hand navigation, click Tags.
  • Click New.
  1. Tag Configuration:
  • Click inside the Tag Configuration box.
  • Choose Google Analytics: GA4 Configuration.
  • Measurement ID: Paste the ZEALTERCODE0 Measurement ID you copied from Step 1 (your GA4 property).
  • Send a page view event when this configuration loads: Leave this checked. This ensures a “page_view” event is sent to GA4 every time the tag fires.
  • Fields to Set (Optional): You can add custom fields here if needed, but for basic setup, it’s not required.
  • User Properties (Optional): Similarly, for basic setup, not required.
  1. Triggering:
  • Click inside the Triggering box.
  • Select All Pages (the built-in Page View trigger). This means your GA4 configuration tag will fire on every page load.
  1. Name Your Tag:
  • Give your tag a clear name at the top (e.g., “GA4 – Configuration – All Pages”).
  1. Save Your Tag: Click Save in the top right corner.
  2. Submit and Publish Your Container: This is a crucial step! Changes in GTM are not live until you publish them.
  • In the GTM workspace, click the blue Submit button in the top right corner.
  • Version Name: Give your version a descriptive name (e.g., “Initial GA4 Setup”).
  • Version Description (Optional): Add notes about what changes you made (e.g., “Added GA4 base configuration tag”).
  • Click Publish.
  • Why Publish? Publishing creates a new “version” of your container that goes live on your website. Until you publish, your new GA4 tag won’t be active.

Step 5: Verify Your Google Analytics 4 Setup

After publishing, it’s essential to confirm that your GA4 tracking is working correctly.

  1. Use Google Tag Manager’s Preview Mode:
  • In your GTM workspace, click the Preview button (next to Submit).
  • A new window, “Tag Assistant by Google,” will open.
  • Enter your website’s URL (e.g., ZEALTERCODE0) in the “Your website’s URL” field and click Connect.
  • Your website will open in a new tab, and the Tag Assistant window will show debug information.
  • Verification: In the Tag Assistant window, you should see your ZEALTERCODE0 container loaded. In the “Tags Fired” section, look for your “GA4 – Configuration – All Pages” tag. It should show that it fired on the page. You can navigate through your website in the connected tab, and Tag Assistant will update to show which tags fire on each new page.
  1. Check Google Analytics 4 Realtime Reports:
  • Open a new browser tab and go to analytics.google.com.
  • Make sure you’ve selected your newly created GA4 property.
  • In the left-hand navigation, go to Reports > Realtime.
  • Now, on your website (or the tab connected via Tag Assistant), browse a few pages.
  • Verification: Within a few seconds, you should see “Users in last 30 minutes” increase, showing at least 1 user (you!). You’ll also see “Views by page title and screen name” and “Event count by Event name” updating with “pageview” and “sessionstart” events. This confirms your GA4 data is flowing correctly.
  • Pro Tip: If you’re not seeing data immediately, try clearing your browser cache or using an incognito window for testing. Ad blockers can also prevent tracking, so temporarily disable them if you suspect an issue.

Helpful Tips & Troubleshooting

  • Cache: If you make changes and don’t see them reflected, clear your WordPress caching plugin (e.g., WP Rocket, LiteSpeed Cache) and your browser cache.
  • Ad Blockers: Browser extensions like AdBlock Plus or uBlock Origin can prevent Google Analytics and Google Tag Manager from loading. Disable them when testing.
  • Double Check IDs: Ensure you’ve correctly copied and pasted the GA4 Measurement ID (ZEALTERCODE0) into GTM, and that Site Kit is connected to the correct GTM container (ZEALTERCODE1). A single typo can break tracking.
  • No Data in Realtime Report?
  • Confirm your GTM container is published (Step 4, part 7).
  • Verify the GA4 configuration tag fired in GTM Preview mode (Step 5, part 1).
  • Ensure no ad blockers are active.
  • Wait a few minutes; sometimes there’s a slight delay.
  • One GTM Container Per Site: Avoid installing multiple GTM containers on the same website, as this can lead to unpredictable tracking and data discrepancies.
  • Beyond Page Views: This setup provides basic page view tracking. The true power of GTM and GA4 comes from tracking custom events (button clicks, form submissions, video plays, etc.). You’ll configure these as new tags and triggers within GTM.

Congratulations! You’ve successfully set up Google Analytics 4 on your WordPress website using Google Tag Manager. You’re now equipped to collect valuable data that will inform your content strategy, user experience improvements, and overall website growth. Embrace the power of data, and keep exploring the possibilities within GA4 and GTM!


Was this helpful?

Previous Article

As an expert educator, I'm here to guide you through creating an essential component of any professional website: a custom contact form. While many "how to start a WordPress blog" guides exist, they often skim over the details of truly customizing crucial elements. Today, we'll dive deep into using Contact Form 7, a powerful and free plugin, to build a contact form tailored to your specific needs, ensure it works correctly, and integrate it seamlessly into your WordPress site.

Next Article

Mastering Basic SEO for Your WordPress Posts Using Yoast SEO

Write a Comment

Leave a Comment