{"id":197928,"date":"2016-08-10T18:22:04","date_gmt":"2016-08-10T18:22:04","guid":{"rendered":"http:\/\/optimizerwp.com\/?p=197928"},"modified":"2017-01-14T02:40:46","modified_gmt":"2017-01-14T02:40:46","slug":"google-analytics-wordpress","status":"publish","type":"post","link":"https:\/\/optimizerwp.com\/google-analytics-wordpress\/","title":{"rendered":"How to Install Google Analytics in WordPress"},"content":{"rendered":"<p>Running a website involves a lot of guesswork. You need to guess what kind of design your visitors like and don\u2019t like, which type of content they are interested in and how they are going to interact with it.To make matters worse, there\u2019s no way of knowing this until your site is online. And while best practices exist, you will only know if your guesses were right once everything is already out there.<\/p>\n<p>Luckily, there is a way of tracking your visitors\u2019 every move and look over their shoulder while they browse around your site. We are, of course, talking about web analytics, the most popular of which is Google Analytics.No wonder. The platform is free, powerful and can be used by anyone.<\/p>\n<p>For that reason, in this tutorial we will not only talk about why installing web analytics on your site is a good idea but also show you how to install Google Analytics in WordPress in several ways.<\/p>\n<p>&nbsp;<\/p>\n<p>Strap in and let\u2019s get tracking.<\/p>\n<h2>Why Install Google Analytics?<\/h2>\n<p>As mentioned, Google Analytics takes the guesswork out of running your website. Instead of theorizing about who your visitors are and what they want and need, analytics can provide you with definitive data on these topics.<\/p>\n<p>Among other things, Google Analytics can tell you the following:<\/p>\n<ul>\n<li>Which countries your visitors are coming from<\/li>\n<li>The devices they use to access your site (desktop, mobile)<\/li>\n<li>How long they stay on your site and the information they are interested in<\/li>\n<li>At what time they come by (so you can time your publishing schedule accordingly)<\/li>\n<li>Which sites are sending visitors to you<\/li>\n<li>The keywords that bring them to your site<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Pretty useful, huh? And that\u2019s far from everything. Thus, by installing Google Analytics on your WordPress site, you can get to know the people visiting it better than yourself and now you will learn how to do it.<\/p>\n<h2>How to Install Google Analytics Manually<\/h2>\n<p>First, let\u2019s look at how to install Google Analytics by hand. Further below, you will also learn to do the same thing via plugin.<\/p>\n<h3>Create a Google Analytics Account<\/h3>\n<p>As a very first step, you need to create a Google Analytics account. If you create a Google account before (such as for your email), you are already halfway there. Everyone else will need to set one up first.<\/p>\n<p>&nbsp;<\/p>\n<p>To do so, first head on over to the <a href=\"https:\/\/www.google.com\/analytics\/\" target=\"_blank\" rel=\"noopener\">Google Analytics page<\/a>. Here, hit <em>Create Account <\/em>at the top. In the next screen, click again on <em>Create Account<\/em>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-197933 size-full\" src=\"http:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-2.jpg\" alt=\"Create Google Analytics Account\" width=\"1287\" height=\"671\" srcset=\"https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-2.jpg 1287w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-2-300x156.jpg 300w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-2-768x400.jpg 768w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-2-1024x534.jpg 1024w\" sizes=\"auto, (max-width: 1287px) 100vw, 1287px\" \/><\/p>\n<p>This will take you to the following screen:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-197934 size-full\" src=\"http:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-3.jpg\" alt=\"Google Analytics WordPress\" width=\"1287\" height=\"818\" srcset=\"https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-3.jpg 1287w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-3-300x191.jpg 300w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-3-768x488.jpg 768w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-3-1024x651.jpg 1024w\" sizes=\"auto, (max-width: 1287px) 100vw, 1287px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>One there, input the information asked from you. Make sure to provide a valid email address as it will be used to verify your new account. When you are done hit <em>Next Step<\/em>. You will then be asked to click on the verification link in the email Google sent you.<\/p>\n<p>After you have done so, it\u2019s time to return to the Analytics home page, only this time, click <em>Sign in<\/em>. Click the <em>Sign up<\/em> button on the right and you are ready to add your first website.<\/p>\n<h3>Add Your Site<\/h3>\n<p>Next up, you will have to input information about the site you want to track.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-197935 size-full\" src=\"http:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-4.jpg\" alt=\"Analytics Account Details\" width=\"1000\" height=\"511\" srcset=\"https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-4.jpg 1000w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-4-300x153.jpg 300w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-4-768x392.jpg 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<p>Naturally, the choice for the first option is <em>Website<\/em>.<\/p>\n<p>After that, it\u2019s time to create an account name. An account is an entity which can contain one or several websites. Therefore, it makes sense to give it a name topical name such as <em>business websites<\/em> or similar.<\/p>\n<p>Then it\u2019s time to set up the property, i.e. your website. First, type in a name. This will usually the name of your domain. Then, provide the web address of your site.<\/p>\n<p>After that, you can pick from a number of industry categories. Select the one that fits your site best. Then, after setting up the correct time zone, we can move on to the <em>Data Sharing Settings<\/em>.<\/p>\n<p>In this area you can determine how much data access you want to give Google and their employees in order to improve their services. The choice is up to you.<\/p>\n<p>When you are done with the configuration it\u2019s time to click <em>Get Tracking ID<\/em>. This might result in being asked to agree to Google\u2019s terms and conditions before you will land on a page like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-197936 size-full\" src=\"http:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-5.jpg\" alt=\"Google Analytics Tracking code\" width=\"1056\" height=\"591\" srcset=\"https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-5.jpg 1056w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-5-300x168.jpg 300w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-5-768x430.jpg 768w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-5-1024x573.jpg 1024w\" sizes=\"auto, (max-width: 1056px) 100vw, 1056px\" \/><\/p>\n<p>As you can see, it contains both your tracking ID and some code to use it on your website. Leave this page open, we will need it in the next step.<\/p>\n<h3>Add the Tracking ID to Your Site<\/h3>\n<p>The code you find on the page needs to be put into the head section of all pages on your website you want Google to track.<\/p>\n<p>If you decided to do this manually, you have two different choices: either paste the code directly in your <em>header.php<\/em> or add it to your site via <em>functions.php<\/em><\/p>\n<p>For the first part, open your <em>header.php<\/em> file with any text editor and paste the code (including the opening and closing <em>&lt;script&gt;<\/em> tags) right after the <em>&lt;body&gt;<\/em> tag<\/p>\n<p>In <em>functions.php<\/em> you can achieve the same objective with this function<\/p>\n<pre class=\"\">&lt;?php<br \/>\nadd_action('wp_footer', 'add_googleanalytics');<br \/>\nfunction add_googleanalytics() { ?&gt;<br \/>\n\/\/ Paste your Google Analytics code from the previous step here<br \/>\n&lt;?php } ?&gt;<\/pre>\n<p>Please be aware that you really need to know what you are doing. Messing with <em>functions.php<\/em> can break your site if you don\u2019t.<\/p>\n<p>However, that\u2019s it. Now the code is present on your site and Google should start tracking your visitors. Please note that it might take up to 24 hours before you will see any data in your Google Analytics dashboard.<\/p>\n<h2>Adding Google Analytics to WordPress With a Plugin<\/h2>\n<p>Using a plugin to install Google Analytics in WordPress is much easier and involves fewer steps. That\u2019s why many people prefer to go this route.<\/p>\n<p>Be aware that even if you use a plugin to install Google Analytics in WordPress, you always need to set up an account with Google first. Therefore, if you haven\u2019t done so yet, now is the time.<\/p>\n<h3>Install the Plugin<\/h3>\n<p>The most comfortable way to install Google Analytics in WordPress is to use the plugin <a href=\"https:\/\/wordpress.org\/plugins\/google-analytics-for-wordpress\/\" target=\"_blank\" rel=\"noopener\">Google Analytics by MonsterInsights<\/a> (formerly known as <em>Google Analytics by Yoast<\/em>)<\/p>\n<p>To do so, you first need to install it on your site.<\/p>\n<p>For that, log in to your site and go to <em>Plugins &gt; Add New<\/em>. Type in the name of the plugin and hit enter. Find it in the list and click <em>Install Now<\/em>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-197937 size-full\" src=\"http:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-6.jpg\" alt=\"Google Analytics WordPress\" width=\"1120\" height=\"447\" srcset=\"https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-6.jpg 1120w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-6-300x120.jpg 300w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-6-768x307.jpg 768w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-6-1024x409.jpg 1024w\" sizes=\"auto, (max-width: 1120px) 100vw, 1120px\" \/><\/p>\n<p>Don\u2019t forget to activate after it\u2019s done!<\/p>\n<h3>Connect to Google Analytics<\/h3>\n<p>Once that\u2019s over, there will be a new icon called <em>Insights<\/em> in WordPress main menu. Hover over it and click on <em>settings<\/em>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-197938 size-full\" src=\"http:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-7.jpg\" alt=\"Analytics WordPress Settings\" width=\"664\" height=\"618\" srcset=\"https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-7.jpg 664w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-7-300x279.jpg 300w\" sizes=\"auto, (max-width: 664px) 100vw, 664px\" \/><\/p>\n<p>In this menu you will find a link that says <em>Authenticate with your Google account<\/em>. Click it.<\/p>\n<p>MonsterInsights will then automatically try to connect with Google to get the necessary tracking code.<\/p>\n<p>Input your credentials if you are not already logged in and allow the plugin to access your analytics data.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-197939\" src=\"http:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-8.jpg\" alt=\"screenshot-8\" width=\"468\" height=\"438\" srcset=\"https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-8.jpg 468w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-8-300x281.jpg 300w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><\/p>\n<p>This will give you a line of code which you will be asked to copy and paste into the highlighted field inside the plugin settings.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-197940 size-full\" src=\"http:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-9.jpg\" alt=\"Google Analytics code\" width=\"648\" height=\"375\" srcset=\"https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-9.jpg 648w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/screenshot-9-300x174.jpg 300w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/p>\n<p>Do so and hit <em>Save authentication code<\/em>.<\/p>\n<p>Now all that\u2019s left to do is pick the right property (aka website) from the drop-down list, save changes and you are done. Easy, wasn\u2019t it? We think so, too!<\/p>\n<h3><\/h3>\n<h3>Additional Plugin Settings<\/h3>\n<p>The neat thing about this plugin is that it can not just connect your site to Google Analytics but also imports data from the dashboard into the WordPress backend.\u00a0Under <em>Insights &gt; Dashboard<\/em>, you can see an overview and reports of your most important website data without logging into Google Analytics. Saves time and effort.\u00a0For the beginning it will be empty but just give it time and you will start seeing some results.<\/p>\n<h2><\/h2>\n<h2>Additional Google Analytics WordPress plugin options<\/h2>\n<p>The plugin above is far from the only option to bring the power of Google Analytics to your WordPress website. There are a few more viable options in the WordPress directory.<\/p>\n<h3><a href=\"https:\/\/wordpress.org\/plugins\/wd-google-analytics\/\" target=\"_blank\" data-saferedirecturl=\"https:\/\/www.google.com\/url?hl=en&amp;q=https:\/\/wordpress.org\/plugins\/wd-google-analytics\/&amp;source=gmail&amp;ust=1474209173834000&amp;usg=AFQjCNGsI8gyzV1niQpY3CtUV6XeLpf0Bg\" rel=\"noopener\">Google Analytics WD<\/a><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-222219 size-full\" src=\"http:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/google_analytics_wd.png\" alt=\"Google Analytics WD\" width=\"800\" height=\"339\" srcset=\"https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/google_analytics_wd.png 800w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/google_analytics_wd-300x127.png 300w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/google_analytics_wd-768x325.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>Google Analytics WD is the most functional WordPress analytics plugin that you can go with. It\u2019s the official certified member of Google Analytics Technology Partners Program, and offers the most advanced tracking, data filtering and reporting functionalities. It provides data reports for your website audience, and enables you to get custom reports based on any metric and dimension. The plugin lets you track custom dimensions to get data for logged in users, post authors, post types and categories, etc. It comes with the goal management functionality and allows you to track targeted activities with pre defined conditions.<\/p>\n<p>Though feature loaded, Google Analytics WD is yet easy to use and manage. It comes with colorful pie charts for reports and is easy to setup and configure. &#8221;<\/p>\n<p>&nbsp;<\/p>\n<h3><a href=\"https:\/\/wordpress.org\/plugins\/google-analytics-dashboard-for-wp\/\" target=\"_blank\" rel=\"noopener\">Google Analytics Dashboard for WP<\/a><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-197944\" src=\"http:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/Google-Analytics-Dashboard-for-WP.jpg\" alt=\"Google-Analytics-Dashboard-for-WP\" width=\"767\" height=\"247\" srcset=\"https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/Google-Analytics-Dashboard-for-WP.jpg 767w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/Google-Analytics-Dashboard-for-WP-300x97.jpg 300w\" sizes=\"auto, (max-width: 767px) 100vw, 767px\" \/><\/p>\n<p>Another solution for connecting WordPress to Google Analytics and importing your tracking data into the dashboard (in real time nonetheless!)<\/p>\n<p>The plugin also offers in-depth reports and you can customize the tracking code via hooks, setting options and much more.<\/p>\n<h3><a href=\"https:\/\/wordpress.org\/plugins\/google-analyticator\/\" target=\"_blank\" rel=\"noopener\">Google Analyticator<\/a><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-197943\" src=\"http:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/Google-Analyticator.jpg\" alt=\"Google-Analyticator\" width=\"769\" height=\"248\" srcset=\"https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/Google-Analyticator.jpg 769w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/Google-Analyticator-300x97.jpg 300w,  https:\/\/optimizerwp.com\/wp-content\/uploads\/2016\/08\/Google-Analyticator-768x248.jpg 768w\" sizes=\"auto, (max-width: 769px) 100vw, 769px\" \/><\/p>\n<p>Install Google Analytics on your site without editing any template files! Comes with several widgets to display your data in the admin area and on the frontend. Plus, many more features.<\/p>\n<h2>Conclusion<\/h2>\n<p>Web analytics are an important tool to understand your visitors and their behavior. Their data can tell you exactly how many people visit your site, where they are coming and what they are up to.\u00a0Google Analytics is one of the most popular solutions out there due to its capabilities and the fact that it is free. It\u2019s a great all round solution for any website owner.<\/p>\n<p>Above, you have learned how to install Google Analytics in WordPress in several ways \u2013 manually and via plugin \u2013\u00a0 so you, too, can take advantage of its awesome powers.<\/p>\n<p>With the collected data you are able to make your site even more attractive and functional for your visitors and provide even more value to them. And that\u2019s what it\u2019s all about, isn\u2019t it?<\/p>\n<p>&nbsp;<\/p>\n<p><em>Do you use Google Analytics? How did you choose to connect it to your site? Any additional tips or thoughts? Let us know in the comment section below!<\/em><\/p>","protected":false},"excerpt":{"rendered":"<p>Running a website involves a lot of guesswork. You need to guess what kind of design your visitors like and don\u2019t like, which type of content they are interested in and how they are going to interact with it.To make matters worse, there\u2019s no way of knowing this until your site is online. And while [&hellip;]<\/p>","protected":false},"author":6210,"featured_media":197947,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[85],"tags":[],"class_list":["post-197928","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/optimizerwp.com\/wp-json\/wp\/v2\/posts\/197928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/optimizerwp.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/optimizerwp.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/optimizerwp.com\/wp-json\/wp\/v2\/users\/6210"}],"replies":[{"embeddable":true,"href":"https:\/\/optimizerwp.com\/wp-json\/wp\/v2\/comments?post=197928"}],"version-history":[{"count":0,"href":"https:\/\/optimizerwp.com\/wp-json\/wp\/v2\/posts\/197928\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/optimizerwp.com\/wp-json\/wp\/v2\/media\/197947"}],"wp:attachment":[{"href":"https:\/\/optimizerwp.com\/wp-json\/wp\/v2\/media?parent=197928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/optimizerwp.com\/wp-json\/wp\/v2\/categories?post=197928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/optimizerwp.com\/wp-json\/wp\/v2\/tags?post=197928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}