{"id":164879,"date":"2017-06-17T13:00:15","date_gmt":"2017-06-17T13:00:15","guid":{"rendered":"https:\/\/premium.wpmudev.org\/blog\/?p=164879"},"modified":"2022-03-22T00:11:27","modified_gmt":"2022-03-22T00:11:27","slug":"google-analytics-tracking-code-wordpress","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/google-analytics-tracking-code-wordpress\/","title":{"rendered":"How To Add Google Analytics To WordPress Without a Plugin"},"content":{"rendered":"<p>When you think about the greatest pairings of all time, you probably think about duos like Batman and Robin, Mickey and Minnie, and peanut butter and jelly. Then again, there <em>is<\/em> the very modern duo of WordPress and Google Analytics.<\/p>\n<p>While they might not make the layman\u2019s list of greatest partners, I bet they\u2019d be pretty high up there for WordPress design, development, and marketing professionals.<\/p>\n<p>If you have a WordPress website, then you should have Google Analytics (GA), too &#8212; no questions asked. It\u2019s not like the two can\u2019t exist without one another (as in any healthy relationship), but I\u2019d argue that the universe just doesn\u2019t seem right when the two aren\u2019t paired up. The question is: how do you make this love connection happen?<\/p>\n<p>Continue reading, or jump ahead using these links:<\/p>\n<ul>\n<li><a href=\"#pairing-google-analytics-tracking-code\">Pairing Google Analytics\u2019 Tracking Code and WordPress<\/a><\/li>\n<li><a href=\"#adding-google-analytics-to-wordpress-using-a-plugin\">Benefits of Adding Google Analytics to WordPress Using a Plugin<\/a><\/li>\n<li><a href=\"#adding-google-analytics-to-wordpress-without-a-plugin\">How to Add Google Analytics to WordPress Without a Plugin<\/a>\n<ul>\n<li><a href=\"#step1\">Step #1: Create a Google Account<\/a><\/li>\n<li><a href=\"#step2\">Step #2: Log in to Google Analytics<\/a><\/li>\n<li><a href=\"#step3\">Step #3: Get Your Google Analytics Tracking ID<\/a><\/li>\n<li><a href=\"#step4\">Step #4: Copy Your Tracking Code<\/a><\/li>\n<li><a href=\"#step5\">Step #5: Log in to WordPress and Add the Code<\/a><\/li>\n<li><a href=\"#step6\">Step #6: Test Your Connection To GA While Waiting<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#more-help\">Need More Help With Your Google Analytics Tracking Code?<\/a><\/li>\n<\/ul>\n<h2 id=\"pairing-google-analytics-tracking-code\">Pairing Google Analytics&#8217; Tracking Code and WordPress<\/h2>\n<p>You\u2019re most likely aware of at least one of three options available to help you connect Google Analytics to your WordPress site:<\/p>\n<ol>\n<li><a href=\"https:\/\/wpmudev.com\/project\/beehive-analytics-pro\/\" target=\"_blank\">Add Google Analytics with a plugin<\/a>;<\/li>\n<li><a href=\"https:\/\/wpmudev.com\/blog\/create-google-analytics-plugin\/\" target=\"_blank\">Create a Google Analytics WordPress plugin<\/a>; or<\/li>\n<li>Add Google Analytics to WordPress without a plugin.<\/li>\n<\/ol>\n<p>That last one? We&#8217;re showing you in this post where to find your Google Analytics code and how to add Google Analytics to WordPress without a plugin.<\/p>\n<p><em>Note: we don&#8217;t recommend adding Google&#8217;s tracking code without a plugin.\u00a0<\/em><\/p>\n<h2 id=\"adding-google-analytics-to-wordpress-using-a-plugin\">Benefits of Adding Google Analytics to WordPress Using a Plugin<\/h2>\n<p>That&#8217;s right. We&#8217;ll show you how and where to add the code for analytics tracking, but we honestly believe either of the other two options will serve you and your website better.<\/p>\n<p>Why?<\/p>\n<ol>\n<li>Adding Google Analytics to WordPress with a plugin is easier, faster, and hassle-free;<\/li>\n<li>If you code GA into WP yourself,\u00a0 you&#8217;ll have to add the Google Analytics code again when you switch themes; and<\/li>\n<li>A <a href=\"https:\/\/wpmudev.com\/project\/beehive-analytics-pro\/\" target=\"_blank\">Google Analytics plugin<\/a> sets up all features automatically, saving you time.<\/li>\n<\/ol>\n<p>Now, we get it. If you want hands-on control of how GA tracks your data, then you&#8217;ve got to add the Google Analytics tracking code manually. Or, if you&#8217;re learning the basics of how WordPress works, then this is an easy task to start with.<\/p>\n<p>Whatever your reasons (and do let us know yours the comments! we&#8217;d love to know), let&#8217;s jump in.<\/p>\n<h2 id=\"adding-google-analytics-to-wordpress-without-a-plugin\">How to Add Google Analytics to WordPress Without a Plugin<\/h2>\n<p>You&#8217;re just six simple steps away from adding the tracking code manually.<\/p>\n<p>Let&#8217;s count them down.<\/p>\n<h3 id=\"step1\">Step #1: Create a Google Account<\/h3>\n<figure id=\"attachment_180607\" class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-180607 size-full\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/06\/GA-Tracking-Code-1-e1572403537373.png\" alt=\"Create a Google Account So You Can Add GA Tracking Code Manually To Your Website\" width=\"600\" height=\"493\" \/><figcaption class=\"wp-caption-text\">Create a Google Account<\/figcaption><\/figure>\n<p><a href=\"https:\/\/accounts.google.com\/SignUp?hl=en\" target=\"_blank\">Create a Google account<\/a> if you haven&#8217;t already, and set up a property &#8212; aka your website.<\/p>\n<h3 id=\"step2\">Step #2: Log in to Google Analytics<\/h3>\n<figure id=\"attachment_180608\" class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-180608 size-full\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/06\/GA-Tracking-Code-2.png\" alt=\"Sign in to Google Analytics\" width=\"600\" height=\"297\" \/><figcaption class=\"wp-caption-text\">Sign in to Google Analytics<\/figcaption><\/figure>\n<div class=\"image-grid cgrid-row\">\n<div class=\"cgrid-col cgrid-col-span-full\">\n<figure id=\"attachment_180609\" class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-180609 size-ratio-large\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/06\/GA-Tracking-Code-3-600x296.png\" alt=\"With your Google account created, you can now sign into Google Analytics. Select your email address and log in.\" width=\"600\" height=\"296\" \/><figcaption class=\"wp-caption-text\">With your Google account created, you can now sign into Google Analytics. Select your email address and log in.<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<h3 id=\"step3\">Step #3: Get Your Google Analytics Tracking ID<\/h3>\n<p>Once you have logged into Google Analytics, go to the Admin area at the bottom-left corner of your Google Analytics dashboard.<\/p>\n<figure id=\"attachment_180610\" class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-180610\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/06\/GA-Tracking-Code-4.png\" alt=\"The Admin area of the Google Analytics Dashboard\" width=\"600\" height=\"464\" \/><figcaption class=\"wp-caption-text\">The Admin area of the Google Analytics Dashboard<\/figcaption><\/figure>\n<p>You\u2019ll see three columns of admin settings controls. In the middle column, click on <strong>Tracking Info<\/strong> and then select the <strong>Tracking Code<\/strong> option.<\/p>\n<figure id=\"attachment_180611\" class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-180611\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/06\/GA-Tracking-Code-5.png\" alt=\"WhereTo Find the Tracking Info for Google Analytics \" width=\"600\" height=\"404\" \/><figcaption class=\"wp-caption-text\">WhereTo Find the Tracking Info for Google Analytics<\/figcaption><\/figure>\n<h3 id=\"step4\">Step #4: Copy Your Tracking Code<\/h3>\n<p>The Tracking Code tab will open and show your property\u2019s unique tracking ID, along with the full Google Analytics tracking code.<\/p>\n<figure id=\"attachment_180612\" class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-180612 size-ratio-large\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/06\/GA-Tracking-Code-6-600x294.png\" alt=\"An Example of Google Analytics Tracking Code\" width=\"600\" height=\"294\" \/><figcaption class=\"wp-caption-text\">An Example of Google Analytics Tracking Code<\/figcaption><\/figure>\n<p>Once you get your GA tracking code, you will need to copy it in full.<\/p>\n<h3 id=\"step5\">Step #5: Log in to WordPress and Add the Code<\/h3>\n<p><em>Note: You should always create a child theme for your WordPress site before editing theme files (as you will in this next step). Check out our post about\u00a0<a href=\"https:\/\/wpmudev.com\/blog\/how-to-create-wordpress-child-theme\/\" target=\"_blank\">How to Create a WordPress Child Theme<\/a> if you need a recap.<\/em><\/p>\n<p>So, where in the HTML of your webpage should you place your analytics tracking code?<\/p>\n<p>Log in to the backend of your WordPress website.<\/p>\n<p>Once logged in, go to the <strong>Appearance &gt; Editor<\/strong> tab in the sidebar. On this screen, you\u2019ll see all of your site\u2019s files displayed to the right, and each file\u2019s Google Analytics code snippet displayed in the middle of the page.<\/p>\n<figure id=\"attachment_180613\" class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-180613\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/06\/GA-Tracking-Code-7.png\" alt=\"Go to Appearance &gt; Editor\" width=\"600\" height=\"357\" \/><figcaption class=\"wp-caption-text\">Go to Appearance &gt; Editor<\/figcaption><\/figure>\n<p>Unless you\u2019re only planning to track visitor activity on certain pages of your website (unlikely), you\u2019ll want to insert the code somewhere that will automatically apply the tracking site-wide.<\/p>\n<p>Where can you do that?<\/p>\n<p>Look for the header.php file along the right-hand side. Click on it to open; the code editor will appear in the middle of your screen.<\/p>\n<p>Look for the closing tag within the code. A simple Ctrl + F will help you quickly locate it.<\/p>\n<figure id=\"attachment_180614\" class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-180614\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/06\/GA-Tracking-Code-8.png\" alt=\"Use your browser\u2019s search function to look for the closing Head tag.\" width=\"600\" height=\"288\" \/><figcaption class=\"wp-caption-text\">Use your browser\u2019s search function to look for the closing head tag<\/figcaption><\/figure>\n<p>Once you find it, insert your cursor just before the tag and paste in your Google Analytics tracking code. Then click on the <strong>Update File<\/strong> button below the code editor to save your changes.<\/p>\n<h3 id=\"step6\">Step #6: Test Your Connection To GA While Waiting<\/h3>\n<p>After adding Google Analytics to WordPress, it takes anywhere from 24 to 48 hours for new data to populate.<\/p>\n<p>So while\u00a0you won\u2019t start seeing the data on any traffic to your site immediately, you can test the connection you\u2019ve established.<\/p>\n<p>Check by returning to the Tracking Code page in Google Analytics. To the right of your Tracking ID is a <strong>Status Update<\/strong>. To confirm everything&#8217;s working properly, click on <strong>Send Test Traffic<\/strong>. This will open your site in a small window.<\/p>\n<p>If all is well, your account should update to show an active user count of 1. Yay!<\/p>\n<p>If the active user count doesn&#8217;t appear immediately, be patient. Google says this can take up to a minute.<\/p>\n<h2 id=\"more-help\">Need More Help With Your Google Analytics Tracking Code?<\/h2>\n<p>If you missed our\u00a0<a href=\"https:\/\/wpmudev.com\/blog\/google-analytics-guide\/\" target=\"_blank\">comprehensive guide to Google Analytics<\/a>, take some time to read through it once everything is set up and ready to go on your WordPress site. It\u2019ll give you a great introduction into what Google Analytics is, what it does, and what you can learn from the insights found within it.<\/p>\n<p>And if you want to get even more granular with your tracking, check out our\u00a0<a href=\"https:\/\/wpmudev.com\/blog\/track-file-downloads\/\" target=\"_blank\">Tracking File Downloads With Google Analytics and WordPress<\/a>.<\/p>\n<p>Are you looking for an easy way to deliver your Google Analytics data to your WordPress clients? Check out <a href=\"https:\/\/wpmudev.com\/blog\/how-to-create-client-pdf-reports-with-wordpress-google-analytics\/\" target=\"_blank\">how you can create pdf reports of GA dashboard data<\/a>.<\/p>\n<h2>Ready? Set? Get Tracking!<\/h2>\n<p>You&#8217;ve come a long way since the start of this article &#8211; from not knowing how or where to put your Google Analytics tracking code, to getting your first test user counted and seeing your Analytics in action.<\/p>\n<p>Congrats!<\/p>\n<p>Now, it&#8217;s time to put what you&#8217;ve learned to work and get that code on your WordPress site.<\/p>\n<p>If you need any help (and you&#8217;re a <a href=\"https:\/\/wpmudev.com\/hub\/my-websites\/\" target=\"_blank\">WPMU DEV member<\/a>), contact our <a href=\"https:\/\/wpmudev.com\/hub\/support\/\" target=\"_blank\">Support experts 24\/7<\/a> with questions. Or, if you&#8217;re still figuring out whether a membership is right for you, post in the comments below. We&#8217;re happy to help you measure the metrics of your WordPress site with Google Analytics, in whatever way we can.<\/p>\n<p>To your success!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you think about the greatest pairings of all time, you probably think about duos like Batman and Robin, Mickey and Minnie, and peanut butter and jelly. Then again, there is the very modern duo of WordPress and Google Analytics. While they might not make the layman\u2019s list of greatest partners, I bet they\u2019d be [&hellip;]<\/p>\n","protected":false},"author":782566,"featured_media":175627,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[263],"tags":[10003,10958,10599],"tutorials_categories":[],"class_list":["post-164879","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-wordpress-plugins","tag-google-analytics","tag-must-have-plugins"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/164879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/782566"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=164879"}],"version-history":[{"count":21,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/164879\/revisions"}],"predecessor-version":[{"id":207728,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/164879\/revisions\/207728"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/175627"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=164879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=164879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=164879"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=164879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}