Google Analytics is the most advanced system of statistics and analytics for your website on the Internet. The site’s attendance, the sources of entry to the site, the most popular pages of the site, the average time of viewing the site and a host of other important parameters are all available in Google Analytics.
To connect Google Analytics to a site on WordPress, you must add a special tracking code for Google Analytics to the site. Although today almost everyone already has a ready account in Google, many frighten off this procedure or it seems complicated.
But believe me, there is absolutely nothing complicated in this. Add the code and start using Google Analytics in 10 minutes. In this lesson, we’ll try in simple language to explain how to add Google Analytics tracking code to the WordPress site.
See also :
Where can I find my tracking code for Google Analytics?
You can add tracking code to the site in several ways. But first, you need to know this code.
Of course, for this, you need to go to the Google Analytics page. If you already have a Google Analytics account, just log in:
If you do not already have a Google Analytics account, you can still click Sign In and following the prompts on the screen, you can create it very quickly. Immediately after creating the account, Google will display your information and Tracking ID on the screen.
Or if you already have a Google Analytics account, just go to Admin → Tracking Info → Tracking Code :
The information we need is made up of two parts:
- Tracking ID – your unique identifier in Google Analytics
- Tracking Code – insertion code to be added to the site (contains Tracking ID)
Copy the Tracking ID and the embed code, now it will all come in handy.
1. We add the code manually
This method is the easiest and fastest. You need to add the tracking code to the file header.php of your active WordPress theme.
Go to menu Appearance → Editor and select the header (header.php) for editing . Insert the copied tracking code right before the closing tag < / head >:
Do not forget to save the changes!
2. Add the code with the plugin Insert Headers and Footers
Although the manual method is considered to be the simplest, it has a drawback. The changes made in this way will be lost if you update the theme or move to another topic.
Therefore, an alternative method is to add the Google Analytics insert code through the plugin. To do this, a free plug-in Insert Headers and Footers :
After installing and activating the plug-in, go to Settings → Insert Headers and Footers . Insert the copied tracking code of Google Analytics in the Scripts in Header section and click Save:
3. Add the code with the plugin Analytics Cat
Unlike the previous plugin, the plugin Analytics Cat is specially sharpened for Google Analytics and has some advantages.
First, as with Insert Headers and Footers, you will be protected from losing track code when changing the skin.
Secondly, the Analytics Cat plug-in allows you to exclude you as a user from the Google Analytics shadowing. After all, you will often go to your site yourself, update plug-ins in the admin panel and so on, why update the statistics on Google with your own activity on the site?
To configure the plugin, just specify Tracking ID you do not need to copy the entire tracking code.
After activating the plugin, simply go to the Settings → Google Analytics Manager menu and insert your Tracking ID. And in the next field you can specify the roles of users that will not be tracked by Google Analytics:
That’s it! Do not forget to click Save.
4. View Google Analytics statistics in the WordPress admin area
As a bonus, we offer you a free plug-in Google Analytics Dashboard for WP with which you can view Google Analytics statistics right in the admin area of your site.
Of course, you will not see all the details and details as on the Google Analytics website, but you will always have basic information about the site’s attendance, and you do not have to deal with the sophisticated and overloaded interface of Google Analytics for a long time. For someone and this will be enough.
After installing and activating the plugin, you will need to go to the WordPress admin menu in the Google Analytics menu and give the plug-in permission to collect data from the Google Analytics service by clicking the Authorize Plugin button:
Follow the prompts to associate the plug-in with your Google Analytics account. After that go to the settings of the plugin in the menu Google Analytics → Tracking Code and configure your tracking code.
After saving the settings, you will be able to see reports and basic statistics from Google Analytics right in the WordPress console.
There are two more plugins for WordPress that do the same: it’s Google Analyticator and Analytify .
We showed you several ways how to easily add the Google Analytics tracking code to the WordPress site.
The manual method is the fastest and easiest. Adding the code to header.php will take 1 minute.
But if you do not want to lose track code when changing the skin, try the plugin Insert Headers and Footers or Analytics Cat .
If you want to view basic Google Analytics statistics in your WordPress admin area, use the Google Analytics Dashboard for WP Google Analyticator or Analytify .