How to Add Google Analytics for Your WordPress Site

Erika Varagouli

Sep 21, 20217 min read
google analytics wordpress

What Is Google Analytics?

Google Analytics is a free analytics tool designed to track website performance and traffic. Many online marketers and SEO professionals use it to optimize websites and applications.
There are 2 Google Analytics properties: 

  • Universal Analytics (UA): Universal Analytics is the earlier version of Google Analytics that offers a comprehensive analysis of website traffic & user behavior and separates traffic into individual channels (organic, paid, social, etc.). This version only supports websites.
  • Google Analytics 4 (GA4): Google Analytics 4 is the newer version of Analytics introduced in late 2020 that offers an overview of website traffic and conversions.
  • This version supports both websites and apps.

Why Is Google Analytics Important?

Google Analytics is currently one of the most comprehensive tools available for tracking web data and traffic. You can use Google Analytics to:

  • Discover how users find your website through different channels
  • Determine what your most valuable pages are
  • Measure conversions and ROI on each channel
  • Track how users interact with your website

Recommended reading: The Beginner's Definitive Guide to Google Analytics

How to Install Google Analytics on WordPress with Plugins

  1. Log into the Google account you want to link to the website.
  2. Open Google Analytics. Create a Google Analytics account by clicking Admin then click Create Account.
google analytics wordpress
  1. Enter an account name. Use a descriptive name or the name of your business. Select all applicable account data sharing settings.
google analytics wordpress
  1. Next, enter the property details. Start with the property name; we suggest using your business name. Enter the reporting time zone and currency.
google analytics wordpress
  1. Select Show advanced options and click the toggle to create a Universal Analytics property. 
google analytics wordpress
  1. Insert the website’s URL in the input. For clients that want a Google Analytics 4 and Universal Analytics property created, select the first option. For clients that only want Universal Analytics property only, select the second option.
google analytics wordpress
  1. As an optional step, fill out the business’ information. This is mainly a survey for Google to capture information about businesses and their analytics needs. 
  2. Select Create. 
google analytics wordpress
  1. Once an account and property have been created, a tracking code installation page will load. This page includes your tracking tag and UA code.
google analytics wordpress
  1. Log into the backend of your Wordpress website. From the menu, select Plugins. Click on Add New to install the UpdraftPlus Website Backup and Insert Headers & Footers plugins. 
google analytics wordpress
google analytics wordpress
  1. Once installed, open the UpdraftPlus plugin and select Settings. Click Backup Now to back up your site. Wait for the backup to finish before implementing any tracking codes.
google analytics wordpress
  1. When your backup completes, toggle back to Google Analytics to copy the tracking code.
google analytics wordpress
  1. In your Wordpress site’s backend, select Settings then the Insert Headers and Footers plugin. 
google analytics wordpress
  1. Paste the Google Analytics code into the Scripts in Header box, then click Save.
google analytics wordpress
  1. To check the code, navigate to the homepage of the website, right-click, then click View Page source. Search for a part of the UA code by hitting Control + F (Windows) or Command + F (Mac). Enter in “Google Analytics” to quickly locate the Analytics code on the page.
google analytics wordpress

How to Access Your GA4 Property Dashboard

  1. With the instructions above, you should have installed both versions of Google Analytics. To access your GA4 property, select the account name from the dropdown arrow at the top left of the screen.
google analytics wordpress
  1. Select the option featuring a series of numbers. This is your GA4 property.
google analytics wordpress
  1. You should be able to view your GA4 property dashboard:
google analytics wordpress

How to Install Google Analytics via Google Tag Manager

What Is Google Tag Manager?

Google offers the Google Tag Manager to help website owners keep track of their tracking codes for a website. You can use Tag Manager to deploy your Universal Analytics property.

To install Google Analytics on your Wordpress site via the Tag Manager:

  1. Follow steps 1-10 as outlined above.
  2. Log into Google Tag Manager using the Google account associated with your Google Analytics account.
  3. On the Workspace Overview screen, click New Tag.
google analytics wordpress
  1. Name the tag Google Analytics Tracking. Click Tag Configuration and choose Universal Analytics.
google analytics wordpress
  1. Select the desired Track Type. Google Tag Manager offers different tracking types that target specific occurrences on your website. For example, use Page View on a website to track which pages your users visit. Use the Event type if you want to track a specific interaction, such as a button click on a promotion.
    google analytics wordpress
  2. Select a Google Analytics Settings Variable. To reuse a Google Analytics Settings Variable that has already been set up, select the desired variable from the menu. Your Google Analytics ID and all other settings from that variable will be applied to your tag.
google analytics wordpress
  1. To set up a new Google Analytics Settings Variable, click New Variable from the dropdown menu. In the variable configuration screen, enter your Google Analytics ID (the UA code from the settings of your Google Analytics account.)
google analytics wordpress
  1. Select New Variable and name the variable Google Analytics Variable. In the Variable Configuration screen, enter your Google Analytics ID. Click Save.
PGM0NBlqcXwuM8OL9UPd3DgY6l0qYjIDCGoY_FFH4pbFE06wn3u2BR8XxYamVkJ2VoPshrF_4syt3vLJawljqzNaIwakg9jvXxgA0wcYna7RByey2XSbjDwKJc9-IcaOb4HtxqTA=s0

If you require additional settings, like custom fields, custom metrics, or content groups, click More Settings to configure the relevant fields.
Note: Cookie Domain: If you have no other Google Analytics tags deployed on your site via analytics.js or from Tag Manager, you should leave this value set to "auto.” If you have other Google Analytics tags set up on your site or in Tag Manager, confirm that the Cookie Domain value is consistent.

  1. Click Triggering to choose a trigger that will make the tag fire: 
google analytics wordpress
  1. You may select an existing trigger, or click the + icon to define a new one.
google analytics wordpress
  1. For this new trigger, we want the tag to fire every time someone lands on a page on a website. Therefore, we’ll name the tag All Page View, click the +, and click Page View to set the trigger to fire on all page views.
google analytics wordpress
  1. Click Save, then go back to the Workspace screen and select Submit at the top to submit all Workspace changes.
google analytics wordpress
  1. Google Tag Manager will show you a tracking code to add to your WordPress website. Copy this code and paste into the Scripts in Header box, then click Save.

Integrating Semrush with Google Analytics

The Semrush tool can read and display certain data from Google Analytics in an easy-to-follow SEO dashboard. However, you benefit most from combining Semrush and Google Analytics data for a comprehensive look at your website’s performance in various Semrush tools. 

Though the tools track similar metrics, their noted differences mean you have more opportunities to monitor traffic, competitor campaigns, do target research and so much more when they’re combined.
Work with the data from each tool to make informed decisions about your website, SEO, and marketing campaigns.

Semrush & Google Analytics Integrations

Google Analytics & Position Tracking Tool

Position tracking with Semrush allows you to import keywords directly from Google Analytics into a position tracking campaign.

On Page SEO Checker (GA & GSC)

The On-Page SEO Checker tool helps you optimize landing pages to rank higher for your target keywords. When connected to GA, the tool allows you to integrate user behavioral data with ways to optimize pages for a better user experience.

The Backlink Audit tool allows you to review your backlink profile and determine whether you have any toxic backlinks to remove or disavow. When connected to GA, you can conduct a traffic analysis of your backlinks.

Organic Traffic Insights (GA & GSC)

Organic Traffic Insights can integrate your GA account to help identify your “not provided” keywords and post-click data in Semrush.

My Reports (GA & GSC)

My Reports allows you to create custom PDFs combining data from multiple tools and data ranges, including GA.

Site Audit (GA)

A site audit tells you all the technical issues with your website. Connect it to GA to add page views to the results of your site audit and run checks for two additional issues: 

  • Pages that take longer than one second to become interactive.
  • Orphaned pages.

Content Analyzer (GA & GSC)

The Content Analyzer discovers content opportunities on your website for SEO and PPC purposes. When it is connected to Google Analytics, you will be able to include data on the number of sessions, page views, and bounce rate associated with each page.

Pairing Content Audit (part of the Content Analyzer tool) with both your Google Analytics and Search Console accounts will ensure that you are getting the most complete and up-to-date data for your pages.

SEO Dashboard (GA & GSC)

The SEO Dashboard gives you a high-level view of your site’s search performance, and linking GA integrates data from your GA account to Semrush to create reports.

Brand Monitoring (GA)

The Brand Monitoring tool helps you track all online mentions of any target keyword or phrase. The tool is perfect for PR professionals and brand managers that want to keep track of how and when their brand is mentioned. Connecting GA allows you to track the referral traffic your brand/website receives through brand mentions that include a backlink to your site.

Marketing Calendar (GA)

The Marketing Calendar allows you to plan and align all of your website and brand marketing campaigns and activities into one place. Connecting to GA allows you to track how your campaigns perform in the Performance tab of this tool.

Track Your Ranking with Ease

with the Position Tracking Tool

ADS illustration

Key Takeaways

Google Analytics is a powerful tool that can give you some powerful insights into your website and its traffic. When you combine this powerful resource with your WordPress website, you can earn a mountain of valuable data you can use to align and adjust your marketing campaigns.

Author Photo
Erika VaragouliI create local and global content marketing strategies here at Semrush. I started my career as a journalist, but gradually the world of SEO and content marketing won me over. I am obsessed with creating content people love, Nick Cave, and Italian films. Fueled by caffeine.
Subscribe to learn more about Technical SEO
By clicking “Subscribe” you agree to Semrush Privacy Policy and consent to Semrush using your contact data for newsletter purposes