How to Connect Google Analytics With WordPress Site
If you already own a WordPress site or are on the way to developing it, you must have linked Google Analytics with WordPress. If you haven’t yet; immediately connect it. Whether it is your WordPress site or other framed site or blog by Blogger or other CMS, without Google Analytics, it is out of imagination to drive it along right direction. As a matter of fact, there is no other alternative to Google Analytics as a free tool around the globe to inquire deep insight into visitors activities with.
However, in this tutorial, we’re going to deal with WordPress site, how to create a Google Analytics account and link it with WordPress blog/site to start tracking visitors’ movement, behavior and numerous other information without any cost.
Also read our Google Analytics starting (Home) post from the link below-
Introduction to Google Analytics with WordPress story
Simply speaking, Google Analytics is a tool or instrument with which you can gather numerous varied types of data regarding visitors engagement in your site/blog/app with full control over target-setting and analytical activities from countless perspectives. For this purpose, you require to connect your Google Analytics account with that site just by following the steps below sequentially—
- Owning a Google ID or Google Account
- Signing in into Google Analytics with Google account
- Setting up a Analytics account and defining a Property (your site/blog) under that account
- Collecting Tracking ID and Tracking Code from corresponding Property.
- Inserting/pasting that Tracking ID and/or Tracking Code in relevant part of your site; especially after <head> tag of site’s html file.
Now let’s have a practical experience of everything—
Google Analytics Chapter of the story
Google Account simply means Gmail Account. One Gmail ID is the Gateway to all the Google Products. There are about one billion (100,00,00,000000) active Gmail users around the globe. I assume you are one among the group. If not, just sign up for a Google ID here.
Follow this Link to Sign in to Google Analytics. You’ll find Sign in to Analytics option upper right corner of the page. Use Log in Credentials of your Google ID to do that.
Follow our another tutorial regarding Google Analytics account and Property setting to have a transparent understanding of the subject.
Integrate Google Analytics with WordPress
You can reach these ID and Code page the following way—
- Log in to Analytics Dashboard
- Click Admin Panel (left below)
- Select your corresponding Account (first column)
- Select Property under that Account (second column)
- Click Menu .js Tracking Info
- Click Sub-menu Tracking Code
You are now redirected to a page where you’ll see your Tracking ID above and Tracking Code is located under ‘Global Site Tag’ option.
You can copy Tracking ID and/or Tracking Code, as you need, from here to set in the relevant field of your site.
Remember, change the Tracking ID field in the Tracking code script by your own Tracking ID if it is not there.
Noted, if you like to track information from more than one of your websites under same Analytics account, define another Property (site) by clicking Create Property above in the Property column and do the same things again.
3 ways to setting up Tracking Code on Self-hosted WordPress site
If your Property is a Self-hosted WordPress site (WordPress site with own Domain-Hosting), you can insert your Analytics Tracking Code 3 different ways—
- By changing header.php file of your WordPress theme
- By using Header and Footer Plugin
- By installing Google Analytics Dashboard Plugin like Monsterinsight.
Change header.php file
The basic rule to inserting Tracking Code into any website is to pasting the code between <head> and </head> tag. It is necessary to set this code in every page of a site. But in case of CMS (Content Management System) websites like WordPress, Blogger, Drupal there are built-in Module or specific process to perform the task. Check-out details of CMS from the following link-
If you’re interested, you can also check out our another guide on how to link Google Analytics with Blogger blog.
However if your use it in WordPress or other CMS platform, it is sufficient to insert the code only once in the relevant field not in every page or post.
Now, to change the header.php file (can be named otherwise irrespective of themes) of your WordPress theme, do the followings—
- Log in to your WordPress Dashboard of the related site.
- Click Appearance→Editor
- Find header.php file titled Theme Header or so and Click it.
- Now find the <head> and </head>. Put your Tracking Code just after <head> or before </head> tag.
- Click Update File button below
- You’re done
Now it may take up to 24 hours for Google Analytics to start tracking visitors from your site and thus show up data in your Analytics Dashboard.
But you can instantly check up whether everything is going OK.
- Enter your Analytics Dashboard
- From Account Link at upper left corner, select your Account→ Property→ View (All Website Data by default).
- Report Page appears. From the left panel, select Real Time→ Overview.
- Real Time Overview Report page appears.
Now enter your related site from any device through any browser. If everything is OK, this will show as changeable Active user number on Top left.
Use Header and Footer plugin
Inserting Code in the theme’s html may frequently prove inconvenient as this solution gives birth to other problems as well, such as—
- Editing theme is always risky; especially by a non-expert in coding. Slight mistake may cause great harm. This risk may cover up by theme Backup before editing but it is not an easy alternative to Plugin to encounter this problem.
- If theme is switched or changed, the site will get disconnected from Analytics unless the same task (inserting Tracking ID) is redone.
All these problems can be avoided by installing a Header Plugin. There are many such plugins out there among which I recommend one along with Footer script insertion facility. This plugin is Insert Heaters and Footers. You can do all things with it very easily.
Enter your WordPress Dashboard. Just install the Insert Headers and Footers plugin. Now go to Setting. You’ll see a link of the plugin there. Click it and you’ll notice two parts there- Cripts in Header (upper part) and Scripts in Footer (lower part). No hassle, no extra setting needed. Just put your Tracking Code in Header portion which will mean inserting it between <head> and </head> tag of the Theme’s HTML. Now Save and You are done!
Use Google Analytics Dashboard plugin
If you like only to insert different Header script that rightly goes between <head> and </head> tag; then, Insert Heaters and Footers plugin may be your appropriate option.
But if you want to look up the summary of Google Analytics Report at a glance from your WordPress Dashboard, there are many Google Analytics Dashboard plugin. And there are also other plugins with which you can insert Tracking Code and check out Analytics Report Summary at the same time. One of such plugins is Monsterinsight.
In the next step, there is step by step guideline on how to use Monsterinsight.
Contextually, to serve the purpose stated above, Monsterinsight is one of the most popular plugins by which you can use many advanced features like enhanced eCommerce tracking etc. But these advanced facilities are not free but open to Monsterinsight’s pro version users. But what you get in the free version is not trivial at all.
With Monsterinsight, you needn’t insert your Tracking Code anywhere. You have just to authenticate your active Analytics Profile with Google. Monsterinsight will do the rest.
Just follow the steps below—
- Install MonsterInsight Plugin
- You’ll get a Menu saying ‘Insight’ in your Admin Panel.
- Go to Insight→ Setting.
- On Setting page, under General tab, first is the Authentication Option. Perform your Analytics profile authentication. You have nothing to insert. Follow the authentication steps– select Google Account, provide account info if needed, allow access and complete the process and Save Changes.
- Under Tracking tab, there are options also. You can change these if you will and hit Save. And you’re done.
Upon setting completion, a new option ‘Report’ will be added with ‘Insight’ menu. Also an Analytics Report feature will be displayed on Dashboard.
However, if you are serious about Google Analytics Dashboard Report, my recommendation is to use Insert Heaters and Footers plugin and look for another Google Analytics Dashboard plugin that will best suit your need.
That’s all. I think the process to connect Google Analytics with WordPress must have been made simpler to you and removed all your hesitation and darkness. If so, let me know which process best worked for you? Drop a Comment!