Skip to main content
All CollectionsWordPress Tips & Tricks
How To Add Google Analytics to a WordPress Site
How To Add Google Analytics to a WordPress Site

Learn how to seamlessly add Google Analytics to your WordPress site for valuable insights and data-driven optimization.

Christal Jackson avatar
Written by Christal Jackson
Updated over 3 months ago

Understanding your website's traffic and user behavior is crucial for optimizing performance and enhancing user experience. Google Analytics is a powerful tool that provides valuable insights into your website's performance. Here's a step-by-step guide on how to add Google Analytics to your WordPress site.

Step 1: Create a Google Analytics Account

  1. Visit the Google Analytics website and sign in with your Google account.

  2. Click on "Start measuring" to set up a new account.

  3. Enter your account name, website name, and website URL.

  4. Select your industry category and reporting time zone.

  5. Accept the terms of service and click "Create."

Step 2: Get Your Tracking ID

  1. Once your account is set up, navigate to the "Admin" section.

  2. Under the "Property" column, click on "Tracking Info" and then "Tracking Code."

  3. Copy the Global Site Tag (gtag.js) code provided.

Step 3: Add Google Analytics to WordPress There are two common methods to add Google Analytics to WordPress: using a plugin or manually adding the code.

Method 1: Using a Plugin

  1. Install a Plugin: Go to your WordPress dashboard, navigate to "Plugins" > "Add New," and search for "Google Analytics for WordPress" by MonsterInsights or a similar plugin.

  2. Activate the Plugin: Install and activate the plugin.

  3. Connect to Google Analytics: Follow the plugin's instructions to connect your Google Analytics account. This usually involves authorizing the plugin to access your Google account.

Method 2: Manually Adding the Code

  1. Access Theme Editor: In your WordPress dashboard, go to "Appearance" > "Theme Editor."

  2. Edit Header File: Find and select the "header.php" file.

  3. Paste the Tracking Code: Just before the closing </head> tag, paste the Global Site Tag (gtag.js) code you copied earlier.

  4. Save Changes: Save the changes to the header file.

Step 4: Verify Google Analytics Installation

  1. Return to your Google Analytics account.

  2. Click on "Real-Time" > "Overview" to see if your site activity is being tracked.

  3. Visit your website to trigger real-time data and ensure that Google Analytics is working correctly.

Conclusion: Adding Google Analytics to your WordPress site is a straightforward process that provides powerful insights into your website's performance. Whether you choose to use a plugin or manually add the tracking code, you'll be able to make data-driven decisions to optimize your site. Regularly check your analytics to understand your audience and improve your website's effectiveness.

Did this answer your question?