Google Analytics is one of the most essential tools you need to track and optimize the performance of your website. Keep in mind that, no matter how much experience you gain through years of web development, you can never build a perfect website regarding appearance, speed, functionality, and conversions. You can only build and aim to improve your site over time through constant monitoring.
With Google Analytics, you can get access to all the information you need to improve your website. And as the most popular analytics tool in the online world, it makes sense to pair Google Analytics with the most popular web-creation platform – WordPress.
Signing Up for Google Analytics
Before you can use Google Analytics on your WordPress site, you must first register for an account on their website. Keep in mind that you have the option to integrate Google Analytics into a website or mobile app. Make sure the option “Website” is selected before you proceed.
Next, fill in the necessary information such as a website name, URL, industry category, and reporting time zone. Also, don't forget to check the data sharing settings at the bottom of the page. These settings allow you to limit the information that Google can collect from your website.
When done, review your settings and click “Get Tracking ID” at the bottom of the page. Read the ToS agreement or save a copy for later and then click “I Accept.” There, you should be able to find the following information:
- Tracking ID
- The Universal Analytics tracking code
- PHP implementation code
Installing Google Analytics on WordPress
Now that you have the required information, you can now proceed to install Google Analytics on WordPress. There are three ways for you to do this – namely direct pasting, modifying “functions.php,” and using the plugin method.
Direct Pasting
The simplest way to install Google Analytics is to paste the tracking code in the file “header.php” on your WordPress site. To do this, log in to your WordPress dashboard and go to Appearance à Editor, choose your current theme, and then look for “header.php” or “Theme Header” under Templates.
Copy the tracking code you received from Google Analytics. Remember that this code is enclosed between the <script> and </script> tags. Paste the entire code right before the </head> tag. Your code should now look like:
Hit “Update File, ” and Google Analytics should be installed on your WordPress site.
Functions.php
The next method requires you to know a little bit about pasting snippets. By navigating back to the Editor section on your WordPress dashboard, look for the “Theme Functions” or “functions.php” file and add the following code:
<?php
add_action( 'wp_footer', 'add_googleanalytics' );
function add_googleanalytics() { ?>
**Paste your Universal Analytics tracking code here**
<?php } ?>
After adding the code, click “Update File” to install Google Analytics.
Using a Plugin
Finally, you can use an automated tool to inject the Google Analytics code into your WordPress site automatically. This method is perfect for beginners who don't want to mess with their site's code.
All you need to do is to download the Insert Headers and Footers plugin and paste the Google Analytics code in its settings page. This section can be found by going to your WordPress dashboard à Settings à Insert Headers and Footers.
Conclusion
Google Analytics is an excellent way to keep track of your website and devise plans for optimization. You can use any of the methods above to install the app and get started.