How to Add Google Analytics in WordPress Site?
It is important to monitor the traffic and other statistical data of your WordPress site. This helps in taking corrective actions when something is going wrong. There are many tools like Jetpack traffic monitoring and other readymade plugins to see the status and reports right from the admin dashboard. But Google Analytics is one of the free tools with exhaustive features and mandatorily required to be integrated on each WordPress site. For example, if you are looking for selling your website then the first traffic proof to be shown to the buyer is the data from Google Analytics. In this article we will explore the possibilities of adding Google Analytics in WordPress site.
How to Get Google Analytics Code?
You need to have a Google account in order to get the Analytics code from Google. Go to Google Analytics website and login with your Gmail account, if you don’t have a one then signup for a new account. Once you are logged inside Analytics account then click on the “Admin” tab and create new account for your website.
Fill all the required details like account name, website name, website URL, etc. and click on the “Get Tracking ID” button.
Initially the status of the tracking will be showing as “No data received in past 48 hours”. Just ignore the status message and copy the Analytics script code to the clipboard.
You can add the code on your WordPress site either manually or using a plugin.
Manually Adding Google Analytics in WordPress Site
The first option is to integrate Analytics code on your site manually without any plugin. Login to your WordPress dashboard and navigate to “Appearance > Editor” section. Choose header PHP template “header.php” and paste the Google Analytics code just before the closure of head tag. This will add the Analytics code on the header area of all the pages on your site.
Save your changes and go back to your Analytics account. Check the status and ensure it shows “Receiving traffic in past 48 hours”. You can also trigger test traffic by clicking the “Send test traffic” button and see the active user count is increased by one.
Adding Analytics Code Using Plugin
Google Analytics by Yoast was one of the popular plugins used to add Analytics code on your WordPress site. The plugin was recently bought by Syed Balki founder of wpbeginnner.com and renamed as Google Analytics by MonsterInsights.
Go to “Plugins > Add New” on your admin dashboard and install the plugin. Activating the plugin will create a menu named “Insights” on the sidebar navigation. The plugin offers two ways to add the Analytics code:
- Manually add the Google Analytics UA code.
- Authenticating with Google account login.
The authentication allows you to see the Analytics dashboard right from your WordPress admin dashboard and the manual code addition will just add the code without dashboard access.
In order to add the code manually, go to “Insights > Settings” and navigate to “General” tab. Click on the “Manually enter your UA code” and add your Google Analytics code.
If you want to integrate Analytics dashboard then click on the “Authenticate with your Google account” button.
You will be promoted to login with your Google account and confirm the access to your details. Click on the “Allow” button to provide access.
Once you have successfully authenticated the account, navigate to “Insights > Dashboard” to view the Analytics dashboard.