Google offers some of the best analytics software on the web. You can use it to monitor pageviews (traffic to your site), complete with demographic and location information. You can also view your current traffic in realtime, or really dig into reports about user behavior. But how do you add Google Analytics to a WordPress page? Here are a few options.
First, you'll need to register for a free Google Analytics account, so make sure to do that if you haven't already. Now we'll get you set up!
Is your WordPress site run on WordPress.com? You don't need to bother with plugins or modifying themes: support for Google Analytics is built in. Head to Settings > Traffic and you'll find a place to paste your embed code, no plugins or hacks needed. Read more at Wordpress.com.
How to Add Google Analytics to a WordPress Site With a Plugin
The simplest way to add the Google Analytics tracking code to your WordPress site so you can start learning about the people who browse your website. There are various options for the job but GA Google Analytics is clean and open source. To install it head to the Plugins section of your WordPress backend, then click Add New.
Search for GA Google Analytics and activate it. Next, you’re going to need to find your Google Analytics UA code. Head to Google Analytics, open the panel for the site you’re trying to add, then click Admin.
Next click Property Settings.
You will find your Tracking Id right at the top of this panel. Make sure to include the entire ID, including the
UA- at the beginning and
-1 at the end.
Now head back to your WordPress site and head to Plugins, then the settings for your plugin. Here’s how that looks for GA Analytics:
In GA Google Analytics you’ll need to open the Plugin Settings section.
Next, paste your GA Tracking ID in the appropriate box.
Click Save and you’re done!
Adding Google Analytics to a WordPress Site By Editing Your Theme
Don’t want to install a plugin just for Google Analytics? You can add the code manually to your theme. This is only recommended for advanced WordPress users. There’s a clear downside here: any updates to your theme will break the Analytics embed, so if you do this you’ll need to either avoid updating the theme or be willing to re-edit it. Still, if you want to avoid a plugin, this is the go-to method.
To get started you’ll need to find your Google Analytics tracking code. Open Google Analytics for the site you want to add, then click Admin in the bottom-left corner.
Click Tracking info...
...then click Tracking Code.
Copy the code in the Global Site Tag box.
Now head to your WordPress site and click Appearance > Theme Editor.
You will be warned about editing your theme. Click I understand to continue.
Now you can paste in the Analytics code you copied above. Make sure you put it above the
Click Update File and you're done.
You've now added Google Analytics to your website, so you can start learning about the people who browse it.
Want to get more out of Google Analytics? Zapier offers Google Analytics integrations, which connects Analytics with 1,000+ apps.