So you are looking for information about where to put google analytics code in WordPress. There are 3 ways to install google analytics in WordPress. They are:
Install a WordPress plugin that could handle the job. (PREFERRED method)
Add a code to functions.php file in your theme. (NOT RECOMMENDED)
Add google analytics tracking code to header.php file located under your theme folder. (preferred method for high-traffic blogs)
How to set up Google Analytics with a plugin
This is the easiest method and newbies should prefer this one. The downside of installing analytics with a wordpress plugin is that your blog will slow down a liitle bit due to an additional plugin. However, 99.9% of the time, this is not an issue. The advantage of this method is that it is easy, user-friendly and requires less time.
There are tons of wordpress plugins that you can use to install Google Analytics. You can search the plugin directory to find a one. Best Google Analytics WordPress plugin is simply Google Analytics for WordPress developed by Joost de Valk. You don’t even need to copy and paste the tracking code. The plugin asks you to grant access for google analytics, then you are done. It is very simple and user friendly. Watch the video on plugin homepage prior to plugin installation.
Do not mess with functions.php
Second method, adding code to functions.php, is not recommended. There are some tutorials that describes how to install Google Analytics by placing a php code to functions.php file in your theme. If you are newbie, you should avoid this approach. The reason is simple. If you mess up, you will hard time restoring your wordpress blog. You can always restore the original functions.php; however, it requires a little bit technical knowledge and patience. Here is a screenshot I found online for a WordPress blogger who placed the php code wrong in functions.php.
Even if you can do it properly, you should do your best not to modify functions.php. If you follow online tutorials for a long time, you will make various changes to functions.php. After some time, it will be difficult to manage those modifications. If something stops working, you have to go over those code snippets one by one to resolve the issue. Believe me, this will eliminate headaches and save a lot of time in the long run.
How to add Google Analytics to WordPress blog
It is easier to set up Google Analytics with a WordPress plugin; however, this causes slight performance degradation. For a high-traffic blog, even a 1% increase in page load time could make a difference. A plugin modifies the way your WordPress blog functions. When a visitor requests a webpage, plugin calls slow down the performance of the blog. Therefore, one should install Google Analytics tracking code directly into theme files. So the ultimate question becomes Where to put google analytics code in WordPress…
It is a better practice to use the new Google Analytics tracking code in the head of your webpage, it won’t hold back the rest of your page from loading. Moreover, it won’t be delayed by the rest of the webpage either. It will start functioning sooner, and you will have more accurate visitor data. If you put the tracking code all the way to the bottom of the page and your visitor left the page before tracking code is fired, those visitors are recorded as a direct visit. Therefore, you will have inaccurate visitor data.
Here are the steps to install Google Analytics tracking code on WordPress:
Login as an admin to wordpress
Go to Appearance > Editor
Select the header.php
Find the </head> html tag
Paste the Google Analytics code before the </head> tag.
Click Update File to save changes.
If you have questions or want us to install Google Analytics code, you can contact us.