How to Set Up Google Analytics for Your WordPress Website

How to Set Up Google Analytics for Your WordPress Website
For a long time, I ignored Google Analytics. For some reason, understanding the how-to and why of Analytics always appeared to be an overwhelming task, and so I kept delaying the process of researching it. But, why even bother having a web presence if you don’t actually know what it’s doing or if it’s working?

So one day, I sat down and opened what ended up totaling 52 browser tabs to finally face the beast that is Google Analytics.

If you’re anything like me; a person who sometimes puts important things into a (metaphorical) box labeled “Future Problems”; then maybe this blog post will help. I’ve broken this article into three sections, which explain:

  • The benefits of using Google Analytics,
  • A detailed step-by-step guide of how to set up Google Analytics, and
  • A brief overview of the features on the Google Analytics dashboard.

Save yourself the hours of research – and avoid the myriad of open tabs in your browser – and read the following guide to help you set up Google Analytics for your WordPress website.


Whether you are a business owner in charge of your company’s website, or a web developer who creates sites for multiple clients, signing up for and becoming familiar with Google Analytics will add significant value to your services or the marketing thereof.

Google Analytics is a free web analytics platform which allows you to gain an understanding of your website’s traffic. Analytics presents you with a series of data reports that give insight into a website’s audience and their demographics, offering information such as; who visits your website, the duration of their visit and what they do when they’re on your website. Google Analytics also offers a range of advanced features, including goal tracking and conversions monitoring. These are exciting avenues that can be explored once you’ve mastered the fundamentals.

Through Google Analytics, you’ll be able to find out how a web audience interacts with your website and based on patterns in the data, you’ll be able to turn insights into action points toward developing better communication strategies based on your audience. Here, you’ll be able to tailor the best possible experience of your website and steer your audience toward executing your objectives (of either purchasing your product or using your services).

If you are a web developer and have a client or number of clients, Google Analytics could offer great opportunities for you to develop long-term relations with your clients on a retainer base, as periodic data reports and strategic recommendations could tie in well with a website maintenance plan.



First, you will need to create a Google Analytics account.
For this, you will need to sign-in to your Google Account. If you don’t already have a Google Account, you’ll need to create one. If you are setting up Analytics on behalf of a client, make sure to discuss the roles related to their data management and their involvement roles beforehand.
Once you’ve signed up, you’ll need to create a New Account.
Select Website as your New Account, and enter the correct details correlating to your website. Be sure to accept the Google Analytics terms and conditions agreements before proceeding to the next step.
Once setup is complete, you will be presented with a Google Analytics JavaScript tracking code.

COPY this code (from the opening <script> tag to the closing </script> tag) and open your WordPress Dashboard.


You’ll need to PASTE the JavaScript tracking code within the <head> of your website; the final entry before the </head> closing tag. In static web builds, the tracking code is inserted into each page of a website, but through WordPress, the code only needs to be entered into one file which will populate across all of the current and future pages as well as posts on your website.
There are a number of methods for integrating your Google Analytics Tracking Code with your WordPress website. Choose whichever method feels most comfortable to you.
If you’re using Divi by Elegant Themes, integrating your Google Analytics Tracking code is easy.

  • Simply navigate to the Divi tab on your WordPress Dashboard and select Divi Theme Options
  • Select Integration on the navigation bar
  • Scroll down, and paste the copied Google Analytics tracking code into the <head> or <body> text area (Although the integration tab recommends the <body> area, either will suffice due to the powerful nature of the Divi theme)
  • Click Save Changes
There are a number of plugins suited to integrating Google Analytics into your WordPress website. Where some offer the nuts and bolts of integrating the tracking code, others offer full data and statistics reporting from right within your WordPress dashboard for convenience. If you’re a person who would benefit from having the data readily available from your Dashboard, this is a great option for you, but if you prefer an uncluttered dashboard rather opt for an alternate integration method.

Two of the most popular plugins offered are Google Analytics by Monster Insights (previously Google Analytics by Yoast) and Google Analytics Dashboard for WP.

When deciding which plugin to opt for, look for consumer reviews and the number of active installs (for credibility), as well as the date of the latest update (for reliability and bug fixes). Once ready to install, either visit the Plugins Directory or navigate to Plugins > Add New from within your WordPress Dashboard, and search for the desired plugin.

Whichever plugin you chose should come with support and explanation documentation, and in some cases, a walk-through tour of the plugin’s features. After you’ve installed the plugin, make sure to search for the respective plugin’s process guide for integrating Google Analytics. You’ll need to authenticate your Google Account and possibly reenter your Google Analytics Tracking Code so keep it close by.

If you’re a seasoned developer, editing your theme’s .php files will be super easy for you.

For less experienced users, try one of the alternate methods suggested above. Editing a theme’s core files could result in catastrophe if not done correctly – even more so if you’re not running a child theme.

  1. From your WordPress Dashboard, locate the header.php file; Appearance > Editor > header.php and paste your Google Analytics tracking code before the closing </head> tag, or;
  2. From your WordPress Dashboard, locate the functions.php file; Appearance > Editor > functions.php, enter a custom function (similar to the code below) and include the Google Analytics tracking code.
Once you have successfully integrated your Google Analytics Tracking Code with your WordPress website, allow for up to 24 hours for the data to begin processing.


Now for the fun part: exploring all of the fascinating features that Google Analytics has to offer.

NOTE: If you get stuck, check out the vast array of Google’s literature, video content and support documentation .

When you land on the Google Analytics Home page, you’ll be presented with a list of each of your websites, as well as a very short overview of core statistics (including Sessions, Average Session Duration, Bounce Rate and Goal Conversation Rate). If you have a number of websites within your account, you can use the star feature to highlight priority sites for quick and easy viewing. To access the extensive data reports and statistics related to your website, navigate to the Reporting tab.

For the most part, focusing on the three key areas of Audience, Acquisition and Behavior are good starting points when beginning with Google Analytics. The rest of the features within the Reporting tab are great to explore over time but are not drastically important in the initial stages.

Dashboards: As well as giving you an overview of important statistics, you’re also able to create a custom report; from a blank canvas; that allows you to customize your dashboard. This way, you’ll be able to view your most important data without working through the standard presented reports.

Shortcuts: Simply put, shortcuts allow you to view specific Google Analytics Reports within your Home page. Shortcuts can be set up from any report by simply clicking on the Shortcuts button on the topmost bar.

Intelligence Events: Here, you’re able to monitor noteworthy changes in your website’s traffic, and furthermore, set up an alert for when specific changes in traffic occur (as defined by conditions; for either a daily, weekly or monthly event; from a broad range of parameters).

Real Time: For a live report of the exact activity on your site at any given moment, select Real Time reports to receive key insights into the Top Referrals, Top Social Traffic and Top Keywords that your users are currently engaging with.

Audience: These reports offer detailed information regarding your website’s audience. Here, you’ll be able to view your website’s users through an array of segmentation variables (from demographics, geographical location, user engagement, browsing behavior and technology use). These statistics can produce key insights that can be turned into objectives for future campaigns, user targeting strategies and marketing efforts.

Acquisition: Offering a detailed view into the nature of how your users arrived at your site, the Acquisition reports break down traffic funnels in terms of referrals, paid search results, organic search results and social media channels. Furthermore, Acquisition reports are integrated with search engine console as well Google AdWords reports (for this, both Google Search Console and AdWords accounts must be set up and linked).

Behavior: Here, you’ll be able to elicit information about what your users are doing while they are on your website, and through the use of Behavior Flow, you’ll be able to determine your most popular pages and view your users’ journey.

In summary, Google Analytics is an extremely powerful tool that will help you understanding your website’s traffic and users.

If you’re interested in exploring the full scope of Google Analytics and its abilities, consider enrolling in the Google Analytics Academy; a free online learning course for training in Google Analytics and data analysis. Then, if you’re super serious about calling yourself an Analytics Guru, consider taking the Google Analytics IQ exam, which upon completion of, you’ll receive a recognized qualification.

If you’re a web developer and are looking to set up retainer-based support for your clients, a Google recognized Analytics qualification could enhance your service offering, and paycheck, quite nicely.

We hope that this blog post has encouraged you to sign up for and start using Google Analytics. If you’re already an Analytics user, why not share with us some of your Aha! moments and what you found most beneficial.

If you enjoyed this post, please feel free share your comments or questions below.

Thanks for reading!

Lisa-Robyn Keown

Lisa-Robyn is a qualified copywriter and brand strategist from Cape Town, South Africa.