MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.


I'm not curious

How to Implement Google Analytics in WordPress?

Published on 31 March 17
1225
0
0
How to Implement Google Analytics in WordPress? - Image 1

Making decisions that are compelled by data, rather than intuition, makes big websites stay on top. To make data-driven decisions, webmasters need some kind of analytics tool. Though there are several of those out there, it is highly unlikely that you will need anything more than Google Analytics.


This free tool enables you to see the strong sides of your website and help you improve them further; but, what is more important, it will help with pinpointing any weak points. With Google Analytics, you can see who is visiting your website, their location, the device they are using, how long they are staying on your website, how many pages they visit in a single session, and a great deal of other metrics. So, how do we get Google Analytics to work on a WordPress-powered website?
Adding Google Analytics with plugins

There is no secret behind the stellar success of WordPress, it is simple to setup and easy to maintain. One of the most important ingredients of its success are plugins. Plugins are special add-ons that improve the overall functionality of WordPress. Today, there are over 40,000 available plugins for this platform.


Among those 40K plugins, there are more than a dozen that help you implement the Google Analytics tracking code, and some even add GUI in the WordPress dashboard that lets you see the summary data without the need of visiting google.com/analytics.
How to Implement Google Analytics in WordPress? - Image 2
Prior to installing any plugins, you will have to register an account with Google Analytics and get your tracking code. Once that is done, save the tracking code and login into your website’s dashboard.
How to Implement Google Analytics in WordPress? - Image 3

Navigate to plugins and click on add new.

Search for analytics and choose any of the available plugins (this is left to your preference). For the purposes of this article, we installed the Monster Insights plugin. Once you activate it, navigate to its menu and click authenticate with Google.
It will take time for GA to get a scope of your traffic, but when it does, you’ll be able to monitor that traffic through the plugin page in your website dashboard or on the Google Analytics page.
Adding Google Analytics by foot

We don’t want to dispute the usefulness of WordPress plugins, but while they are WP’s strong side, at the same time they are its weakness. One plugin too many and your website will see a massive decrease in loading speed and ultimately decline in visits. The reason this might happen is that users bounce off of websites that take more than 3 seconds to load. In case you already have a high number of plugins installed in your theme, it is best you implement the code by hand.


Though it might seem complicated, adding the tracking code by hand is as simple as copy pasting a few lines of code from Analytics into your header.php file. After registering for Google Analytics, the first page you will see is the one with your tracking code and a piece of JavaScript code that is used to track the data.
How to Implement Google Analytics in WordPress? - Image 4
Copy that piece of code into your clipboard and login to your website dashboard. Navigate to Appearance > Editor. Once there, you will see the back-end of your website. In the righthand side of that window is the list of all the files that are used to power your website. In that list, you need to find the file labeled as header.php. Open that file and paste your code just above the closing tag - </head>.
How to Implement Google Analytics in WordPress? - Image 5
This can also be achieved by editing the functions.php file. Find it the same way you found the header.php and add this:

<?php

add_action('wp_head', 'wpb_add_googleanalytics');

function wpb_add_googleanalytics() { ?>

Your google analytics script code

<?php } ?>
Bear in mind that in case you don’t use a child theme on your website, the code will be deleted every time the theme updates along with other customizations you might have done. That is why having a child theme is recommended.
Conclusion

Google analytics is an essential tool for every webmaster, and if you haven’t already got it on your website, make sure you implement it as soon as possible. In case your website already has too many plugins and you don’t feel comfortable meddling with the website’s code on your own, it is best to turn to a professional web designer in Sydney for help.




How to Implement Google Analytics in WordPress? - Image 1

Making decisions that are compelled by data, rather than intuition, makes big websites stay on top. To make data-driven decisions, webmasters need some kind of analytics tool. Though there are several of those out there, it is highly unlikely that you will need anything more than Google Analytics.

This free tool enables you to see the strong sides of your website and help you improve them further; but, what is more important, it will help with pinpointing any weak points. With Google Analytics, you can see who is visiting your website, their location, the device they are using, how long they are staying on your website, how many pages they visit in a single session, and a great deal of other metrics. So, how do we get Google Analytics to work on a WordPress-powered website?

Adding Google Analytics with plugins

There is no secret behind the stellar success of WordPress, it is simple to setup and easy to maintain. One of the most important ingredients of its success are plugins. Plugins are special add-ons that improve the overall functionality of WordPress. Today, there are over 40,000 available plugins for this platform.

Among those 40K plugins, there are more than a dozen that help you implement the Google Analytics tracking code, and some even add GUI in the WordPress dashboard that lets you see the summary data without the need of visiting google.com/analytics.

How to Implement Google Analytics in WordPress? - Image 2

Prior to installing any plugins, you will have to register an account with Google Analytics and get your tracking code. Once that is done, save the tracking code and login into your website’s dashboard.

How to Implement Google Analytics in WordPress? - Image 3

Navigate to plugins and click on add new.

Search for analytics and choose any of the available plugins (this is left to your preference). For the purposes of this article, we installed the Monster Insights plugin. Once you activate it, navigate to its menu and click authenticate with Google.

It will take time for GA to get a scope of your traffic, but when it does, you’ll be able to monitor that traffic through the plugin page in your website dashboard or on the Google Analytics page.

Adding Google Analytics by foot

We don’t want to dispute the usefulness of WordPress plugins, but while they are WP’s strong side, at the same time they are its weakness. One plugin too many and your website will see a massive decrease in loading speed and ultimately decline in visits. The reason this might happen is that users bounce off of websites that take more than 3 seconds to load. In case you already have a high number of plugins installed in your theme, it is best you implement the code by hand.

Though it might seem complicated, adding the tracking code by hand is as simple as copy pasting a few lines of code from Analytics into your header.php file. After registering for Google Analytics, the first page you will see is the one with your tracking code and a piece of JavaScript code that is used to track the data.

How to Implement Google Analytics in WordPress? - Image 4

Copy that piece of code into your clipboard and login to your website dashboard. Navigate to Appearance > Editor. Once there, you will see the back-end of your website. In the righthand side of that window is the list of all the files that are used to power your website. In that list, you need to find the file labeled as header.php. Open that file and paste your code just above the closing tag - .

How to Implement Google Analytics in WordPress? - Image 5

This can also be achieved by editing the functions.php file. Find it the same way you found the header.php and add this:

Bear in mind that in case you don’t use a child theme on your website, the code will be deleted every time the theme updates along with other customizations you might have done. That is why having a child theme is recommended.

Conclusion

Google analytics is an essential tool for every webmaster, and if you haven’t already got it on your website, make sure you implement it as soon as possible. In case your website already has too many plugins and you don’t feel comfortable meddling with the website’s code on your own, it is best to turn to a professional web designer in Sydney for help.

This blog is listed under Open Source , Development & Implementations and E-Commerce Community

Post a Comment

Please notify me the replies via email.

Important:
  • We hope the conversations that take place on MyTechLogy.com will be constructive and thought-provoking.
  • To ensure the quality of the discussion, our moderators may review/edit the comments for clarity and relevance.
  • Comments that are promotional, mean-spirited, or off-topic may be deleted per the moderators' judgment.
You may also be interested in
Awards & Accolades for MyTechLogy
Winner of
REDHERRING
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url

Back to Top