Here are two different ways to add Google Analytics to your WordPress website. First, we need to create an account and an associated property. Then we’ll assign a property code to our website. Here’s how to do all of that:
- Login to Google Analytics using your Gmail login credentials. Bookmark this page for easy access.
- Click on Admin
- Click on Account > Create New Account: This will be the name of your account associated with a single website, or group of websites. If you manage websites for a variety of different clients, each unknown to each other, you should create separate accounts for each client. When you do this, you can grant account access privileges to each client to view analytics data for only their respective website(s) associated with their specific account. In your Admin panel under All Web Site Data, click on User Management to grant and modify account access privileges.
- Click on Property > Create New Property: Properties are your website URL’s. You can have as many properties as you want on a single account. For instance say you have three accounts. Two of these accounts have just one property associated with each one. The third account has four. If one of your clients has ten websites, you can add all ten websites to that client’s account as properties; one property associated with each one of the ten websites.
Each Property is assigned a tracking code and ID. The ID looks like this: UA-XXXXXXXX-X. Depending on which of the following methods you use, you’ll add either the code or ID to begin tracking Google Analytics. Here are descriptions of the two methods:
Install via the header.php file (recommended)
- In the Google Analytics dashboard, go to Account > Property > Tracking Info > Tracking Code
- Copy the website tracking code
- In your WordPress admin dashboard, if you’re using a Child Theme, revert back to its Parent Theme
- Once that’s done, click on Appearance > Editor
- Locate and click on Header (header.php)
- Paste this code just before the closing </head> tag
- Click Update File
Install via the Google Analytics plugin
- In the Google Analytics dashboard, go to Account > Property > Tracking Info
- Copy the tracking ID, which is your property code
- In your WordPress admin dashboard, click on Plugins > Add New
- Search for and install the plugin called Google Analytics
- In your WordPress admin dashboard, click on Settings > Google Analytics
- In the Web Properties field, paste your property code
- Click Save Changes