How to add Google Analytics to WordPress (final Guide)

Whether operating personal blogs or business websites, the goal is to attract more visitors and make them subscribers or shoppers. To successfully operate a site, you must know where visitors come from, how to interact with the site, what pages to move to, and so on. So learn how to add Google Analytics to WordPress and you’ll gain valuable insight into your visitors to help you make decisions and adjust your business strategy. This post will show you how to use various methods to link word press and Google Analytics level by level. Don’t worry even if you don’t have coding technology. There are plug-ins available.
What is Google Analytics and why is it added to word press? Google Analytics (GA) is a completely free analysis solution developed by Google team in 2006, which provides in-depth information of website visitors. The tool is used by most bloggers, marketers, business owners, and anyone who owns a website or application. Today’s Internet has a lot of competition, so it’s important to understand the audience. Google Analytics provides valuable information about traffic and user behavior to help make data-based decisions. The tool provides the following information:
What is the page you read most? How much time do visitors spend on the website? Mobility and mobility? Where are they from? Where did they come from? (natural search, social media, press releases, direct traffic, etc.) are there more mobile or desktop users? There are many others! If you use WordPress or woocommerce to run an online store instead of Google Analytics, you will miss a lot of valuable information! Note: Google Analytics cannot be confused with the search console (GSC). When Google Analytics provides information about visitors and how visitors interact with the site, Google search console will provide information about the people who connect to the site, the keywords with the most searches, and other data to help improve search results.
Google analytics can also be combined with WordPress’s jetpack to provide traffic analysis information. For more information, see the jetpack review. How do I add Google Analytics to WordPress? Now that we have a better understanding of what it is and its advantages, let’s take a look at how to add Google Analytics to word press. With several options, this guide lists three best ways to integrate GA with your site. You can choose to suit your needs.
Header. PHP function. The PHP plug-in Google Analytics requires a Google Analytics account to connect to the website. If there is no account, please create it before starting. Before we start, please note that we have added two ways to modify the core file of wordpress theme. Therefore, before starting, the header. PHP or function. If you want to customize your PHP files and integrate your site with Google Analytics, it is recommended to install sub themes to ensure that changes are not ignored when updating the parent theme. What’s up? Because if you modify a file in a theme instead of a file in a sub theme, when you update the theme, the new file replaces the user definition and loses the modifications.
If you do not want to install subtopics, you can do the following: Create a full backup of the website: if there is a problem, you can restore the website (but the theme) from the backup you created previously
While updating, modifications will continue to be ignored). Using plug-ins: this option is described in Section 3. 1) Header. As can be seen from the PHP title, this method can be used to partially change the title of the website and add Google Analytics tracking code. No matter what WordPress theme is used, it is a header. There is PHP. It contains several PHP code to help display and customize the title section of the website. This may sound complicated, but it’s actually very simple.
A) The first thing to do is to log in to the word press management area. There, click the Theme Editor section under shapes. When opened, WordPress is the style of the following current theme. Displays the CSS file. Male C) all available files in the word press theme directory are displayed on the right. Navigate to the topic title (header. PHP) and click. D) header. Click the PHP editor to insert the file. Male note: do not delete any code from there. This will cause an error in the WordPress website and will not work properly.
E) Now is the title. Because the PHP file is in front, it’s time to import Google Analytics tracking code. To do this, go to the tracking section and copy the code from it. For this purpose, the following path must be followed in GA: Management page > tracking information (under attributes) > tracking code. You must copy the code below from the website trace. F) Then return to the WordPress Theme Editor and paste the tracking code just copied in front of the male tag. You will see: It can be seen from the picture above that a code must be added between the male label and the male label.
G) header. After modifying the PHP file, update the file to save the changes. There are two options to confirm whether it works properly and ensure that everything is correct. You can view the source code at the front of the website, search and analyze the code and confirm it. You can send test traffic in Google Analytics properties and verify whether it is displayed in GA. If the test traffic is sent to the blog, the GA dashboard will update the same information. If you use an advanced word press theme (such as Avada or divi), a dedicated theme panel is included, so you should know that title editing \/ Title includes code insertion options. In this way, theme update will not affect users, and theme customization is safer.
However, if you need more information about customizing titles, see the guide to safely editing word press titles. 2) Function. The second way to add Google Analytics to PHP word press is to modify the theme file. But header. Function instead of editing PHP files. Edit the PHP file. If you have added GA trace code to the header, you do not need to follow other steps. The operation has completed and tracking is enabled for the site. Some people replace functions. You like editing PHP files, so here you’ll learn how to do it step by step.
A) First log in to the WordPress administration area, and then click Theme Editor under shapes. B) Add the style of the current theme. The CSS file is displayed. C) All files in the WordPress theme directory can be found on the right. Click PHP. Functions. D) you can view the function file in the editor. Male E) then copy the code.
\/\/Paste the google analytics code.
Male \/ \/ but paste the google analytics code
The tracking code must be entered at the location marked as. This code can be imported from the Google Analytics tracking section. Management page > tracking information (under attributes) > tracking code > tracking the following code replication website. Therefore, the code will be as follows:

(function (I, s, O, G, R, a, m) {I [\
(i[r].q=i[r].q||[]). Push (factor)}, I [R]. l=1*new Date(); a=s.createElement(o),
m=s.getElementsByTagName(o)[0]; a.async=1; a.src=g; m.parentNode. insertBefore(a,m)
}(window, document, script)“ https:\/\/www.google-analytics.com\/analytics.js ‘,’ga’);
GA (\
GA (\

Male f) then paste the code into the function file and click \
Complete authentication. H) This will display traffic statistics in the report section (please wait, it may take a few minutes). That’s all! Added Google Analytics to WordPress using monster insights! If you purchase the advanced version, you can enable form tracking, Federation link tracking, author tracking and many other functions. Therefore, you can use the plug-in to track the entire website, gain deep insight into potential customers and understand their work and non work. If there are too many WordPress plug-ins, the website may actually slow down (especially those with incorrect coding). However, according to our experience with monster insights, the code is very stable and has no impact on performance. If you need to optimize your site for better speed, check out the list of the best word press caching plug-ins. In short, Google Analytics is an excellent free tool that provides deep insight into visitors and site behavior. Therefore, adding Google Analytics to the WordPress website is necessary to better understand the audience and make business growth decisions. What is the best way? Although the technology and needs are different, it is generally recommended not to modify the subject document. Therefore, integrating Google Analytics with special plug-ins such as monster insights is a great choice. The free version of monster insights includes basic functions, but it is enough to track all pages, find the best posts, etc. If you need more detailed information, you can use the advanced version to expand the functions and enjoy more integration. If you still plan to use the encoding method, the topic updates the header at the time of listing. PHP and functions. Remember that the PHP file will be updated to the new file and all modifications will be lost. You can avoid this by installing the subtopics and making all the changes in them. Another option is to copy the changes before updating the theme, paste them into the new theme version, and re enable Google Analytics tracking. What method would you like to use? If you like this post and learned how to add Google Analytics to WordPress, share and subscribe to newsletters on social media without burden.

Author:

Leave a Reply

Your email address will not be published. Required fields are marked *