{"id":2370,"date":"2021-06-16T13:40:54","date_gmt":"2021-06-16T13:40:54","guid":{"rendered":"https:\/\/www.regexseo.com\/blog\/?p=2370"},"modified":"2022-02-16T15:44:01","modified_gmt":"2022-02-16T15:44:01","slug":"ultimate-ga-goal-tracking-implementation-guide","status":"publish","type":"post","link":"https:\/\/www.regexseo.com\/blog\/ultimate-ga-goal-tracking-implementation-guide\/","title":{"rendered":"Ultimate GA Goal Tracking Implementation Guide"},"content":{"rendered":"\n<p>Welcome to our Google Analytics Goal Tracking guide!<br><br>Today, we\u2019re going to go over how you can track form submissions on your website \u2014 this is a great way to measure how well your website is converting visitors, which is a pretty direct picture of site performance.<\/p>\n\n\n\n<p>It will also give you more insight into what drives these conversions, making it easier to optimize your website and <a href=\"https:\/\/www.regexseo.com\/blog\/7-tips-to-reduce-bounce-rate-and-increase-your-conversions\/\" target=\"_blank\" rel=\"noreferrer noopener\">increase conversion rates<\/a> over time.<br><br>Here are the most common approaches to forms for websites. We\u2019ll go over them on an individual basis, providing detailed explanations on how to add tracking options for each one.<\/p>\n\n\n\n<ul><li>Form with a separate \u2018Thank You\u2019 page<\/li><li>Simple form on a PHP website<\/li><li>Form added using a WordPress Plugin<ul><li>Gravity Forms<\/li><li>Contact Form 7<\/li><li>Elementor<\/li><\/ul><\/li><\/ul>\n\n\n\n<h2><strong>Tracking Prerequisites<\/strong><\/h2>\n\n\n\n<p>To follow along, you\u2019ll need Google Analytics\u2019 gtag script installed on your website.&nbsp;<\/p>\n\n\n\n<p>To check for this, go to your website\u2019s source code in the browser and search for \u201cgtag\u201d. You\u2019ll also need to know how to create goals in analytics, which you can learn by following <a href=\"https:\/\/support.google.com\/analytics\/answer\/1032415?hl=en\" target=\"_blank\" rel=\"nofollow\">this guide<\/a>.<br><br>Next, if you don\u2019t have a \u2018thank you\u2019 page, you\u2019ll need to have a basic understanding of PHP or WordPress form plugins so you can make small changes in the code.<\/p>\n\n\n\n<p>Once you\u2019ve got both of those things, we can dive into the different approaches and implementations for goal tracking on your website.&nbsp;<\/p>\n\n\n\n<h2><strong>Adding Form Tracking using a Thank You page<\/strong><\/h2>\n\n\n\n<p>This is one of the simplest ways to go about tracking.<\/p>\n\n\n\n<p>Generally speaking, the only way users would make it to a thank you page is by completing a form successfully. That means whenever there\u2019s a page visit, you can trigger a form completion event.<\/p>\n\n\n\n<p>To implement a form completion event, you\u2019ll want to select \u201cDestination\u201d in the Goal Description section when you\u2019re setting up the goal in Google Analytics. In Goal Details, just enter the path of your \u2018thank you\u2019 page.&nbsp;<\/p>\n\n\n\n<p>It\u2019ll be something like <strong>\/thankyou.html<\/strong>, instead of the usual <strong>www.yourwebsite.com\/thankyou.html<\/strong> format.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/-Lruiym-kpBJlzp7QdOD_v9CKN2vGVZAoC4oMEL_R9gJr-eIR5jOBLFwOhZOLJYAX5PV9yCbuWjB-ZsNBsG9xfIEg9uiQTy2lXTq1-MBwAY_IkswCBnTJH4djq8lcOFxkWA-lITA\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/IhYYtgwL9lYePATtbFlkNL33XzxT_sJCypNvTc4PaEo25WhCN7CElbdRhrIazz5qFu_aSntEReO2f2nNbCFi0RP2ahaMnxhVZLxzRcND5-W776QCr3lZtXsdDyEiREtvqYtnhY5H\" alt=\"\"\/><\/figure>\n\n\n\n<p>Once you\u2019ve got that set up, just click Save to update your settings. After that\u2019s done, you will have successfully set up form tracking for your website.<\/p>\n\n\n\n<p>This is a pretty simple and direct way to organize form tracking, so if you\u2019re looking for other methods, you\u2019ll have to set up your goals in a different way. We\u2019ll cover that now.<\/p>\n\n\n\n<h2><strong>Google Analytics Goal Set Up<\/strong><\/h2>\n\n\n\n<p>To get started, you\u2019ll want to create an event in Google Analytics. Use this format when you add the event details:<img loading=\"lazy\" src=\"https:\/\/lh5.googleusercontent.com\/oxCPw0Pj4UEFCD-vGviSwXwnecaRi6jGP3xvTiR5qugwMtdgI9y-R_hNbUo17UEn9lDqP855XX3DAxQaHUzQcbE2U8YfxTiosU9_PMf923tXfCjg_LC3v1Rmn6b69wrfNizVhZ8h\" width=\"624\" height=\"317\"><\/p>\n\n\n\n<ul><li>Category &#8211; form<\/li><li>Action &#8211; sent or submit<\/li><li>Label &#8211; contact or inquiry &#8211; anything that helps you identify the form<\/li><li>Value &#8211; (equals to) &#8211; 1<\/li><li>Using Event value for conversion &#8211; Yes<\/li><\/ul>\n\n\n\n<p><br>Note the information you entered here, as you\u2019ll use it for the next steps.<br><\/p>\n\n\n\n<h2><strong>Adding form tracking in a PHP site<\/strong><\/h2>\n\n\n\n<p>This next part is a bit technical if you\u2019re unfamiliar with putting together a website.<br><br>For this method, we\u2019ll need to create a PHP variable to store information that tells us whether the form has been submitted or not.<br><br>When you create this variable, define it before processing form data and set it to false (<strong>$isSubmitted = false<\/strong>). After the form logic has been finished, check to see if the form was submitted. If so, then update this variable to \u2018true\u2019.<br><br>At the very bottom of the page, put an \u2018if\u2019 statement that will check if our variable is true. If it is true, then we\u2019ll specify the gtag script needed for the event.<\/p>\n\n\n\n<p>&lt;?php if (isset($isSumitted) &amp;&amp; $isSumitted == true) { ?&gt;<br>&lt;script&gt;<br>gtag(\u2018event\u2019, \u2018<strong>&lt;event-action&gt;<\/strong>\u2019, {<br>&#8216;event_category&#8217;: &#8216;<strong>&lt;event-category&gt;<\/strong>&#8216;,<br>&#8216;event_label&#8217;: &#8216;<strong>&lt;event-label&gt;<\/strong>&#8216;,<br>&#8216;value&#8217;: 1<br>});<\/p>\n\n\n\n<p>&lt;\/script&gt;<br>&lt;?php } ?&gt;<\/p>\n\n\n\n<p>Replace &lt;event-action&gt;, &lt;event-category&gt;, &lt;event-label&gt; with whatever you defined when creating the goal in Google Analytics.<\/p>\n\n\n\n<h2><strong>Goal Tracking with WordPress Form Plugins<\/strong><\/h2>\n\n\n\n<p>WordPress has a lot of different plugins to help users build and maintain forms, so we\u2019ll cover a few of the most popular plugins. Specifically, we\u2019re looking at Gravity Forms, Contact Form 7, and Elementor.<\/p>\n\n\n\n<h3><strong>Gravity Forms<\/strong><\/h3>\n\n\n\n<p>It\u2019s a bit easier to add tracking to gravity forms compared to the other two plugins. There\u2019s even an extension plugin that simplifies this process.<br><br>If you\u2019re interested, go ahead and <a href=\"https:\/\/wordpress.org\/plugins\/gravity-forms-google-analytics-event-tracking\/\" target=\"_blank\" rel=\"nofollow\">install this plugin<\/a> on your site.<\/p>\n\n\n\n<p>Once installed, this will add a new option under each form\u2019s settings called Submission Tracking.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/3s1ENG_y6ftAAhxlGUn1oG1qLy0PGBWX6BqIz37ucx37nsii5QjsjQ4HlywOiySWpiT1Ngo-gcIAsXfFTnGyBfKXHwjIoCTsM41N6FVIy7Y6ClxCcvcPrYRyErBLepm4LO3HmA9f\" alt=\"\"\/><\/figure>\n\n\n\n<p>Before we can use this plugin, we\u2019ll need to configure it.<\/p>\n\n\n\n<ul><li>Go to Forms &gt; Settings &gt; Event &gt; Tracking<\/li><li>Insert your UA tracking ID (given by Google Analytics) and click save<\/li><li>Go to Forms &gt; Select the form you want to track &gt; Settings &gt; Submission Tracking<\/li><li>Click \u2018Add New\u2019 and enter UA Code (the same you entered earlier)<\/li><li>Add all other event information<\/li><li>Click Save<\/li><\/ul>\n\n\n\n<p>And you\u2019re all set up to track form submissions with Gravity forms.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/74sIcFEvOXze3BORYUk7-A4by58jJ0kQjfZxHEjux67cPAz_pcI2sFmzUzIc0q9zw0joprbirTmdTJCPMjNYbc6wNXBtKmGCe_uD0wBQLFdNI4jtTbk9D36AR5xh2wwk7EgE4e61\" alt=\"\"\/><\/figure>\n\n\n\n<h3><strong>Contact Form 7<\/strong><\/h3>\n\n\n\n<p>Contact Form 7 will take a bit of extra code. You\u2019ll need to add this code to the bottom of the page after your gtag script is initialized. This will most likely be added in the footer.php file.<br><br>However, before we jump into the code, get the <strong>id<\/strong> of the form that you want to track \u2014 this is mentioned when you go to \u2018Contact\u2019 from the menu on the left (as seen below):<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/8s8egH1mG4gmtcfF8r2oGd9tGPniamLEsFbKdN9stmRdbfVNCDouWu5ZAQCVriVHGgzFNz1mxQO8jD_wLqWozaXpL4VwzCMhESQX8p9IpcY9PBOTSEOE19wZWpRpK8-IxM-_Nw_T\" alt=\"\"\/><\/figure>\n\n\n\n<p>Head over to your footer file and add this code:<\/p>\n\n\n\n<p>&lt;script&gt;<br>document.addEventListener( &#8216;wpcf7mailsent&#8217;, function( event ) {<br>if ( &#8216;<strong>&lt;form-id&gt;<\/strong>&#8216; == event.detail.contactFormId ) {<br>gtag(\u2018event\u2019, \u2018<strong>&lt;event-action&gt;<\/strong>\u2019, {<br>&#8216;event_category&#8217;: &#8216;<strong>&lt;event-category&gt;<\/strong>&#8216;,<br>&#8216;event_label&#8217;: &#8216;<strong>&lt;event-label&gt;<\/strong>&#8216;,<br>&#8216;value&#8217;: 1<br>});<br>}<br>}, false );<br>&lt;\/script&gt;<\/p>\n\n\n\n<p>Replace &lt;form-id&gt; with the <strong>form id<\/strong> you got. Replace &lt;event-action&gt;, &lt;event-category&gt;, &lt;event-label&gt; with what was defined when creating the goal in Google Analytics.<\/p>\n\n\n\n<p>The code implementation listens for the event when any form is submitted. Once done, we\u2019ll verify if the submitted form is the one we want to track. If all checks out, we\u2019ll run the gtag script that sends this event to Google Analytics.<\/p>\n\n\n\n<h3><strong>Elementor<\/strong><\/h3>\n\n\n\n<p>For this plugin as well, you\u2019ll need to add some code at the bottom of the page. This code will go after your gtag implementation, which will most likely be in footer.php<\/p>\n\n\n\n<p>Head over to your footer file and add this code:<\/p>\n\n\n\n<p>&lt;script&gt;<br>jQuery( document ).ready(function( $ ){<br>jQuery( document ).on(&#8216;submit_success&#8217;, function(){<br>gtag(\u2018event\u2019, \u2018<strong>&lt;event-action&gt;<\/strong>\u2019, {<br>&#8216;event_category&#8217;: &#8216;<strong>&lt;event-category&gt;<\/strong>&#8216;,<br>&#8216;event_label&#8217;: &#8216;<strong>&lt;event-label&gt;<\/strong>&#8216;,<br>&#8216;value&#8217;: 1<br>});<br>});<br>});<br>&lt;\/script&gt;<\/p>\n\n\n\n<p>Replace &lt;event-action&gt;, &lt;event-category&gt;, &lt;event-label&gt; with what was defined when creating the goal in Google Analytics.<\/p>\n\n\n\n<p>The code implementation listens for the event when the form is submitted. If it\u2019s submitted successfully, we\u2019ll run the gtag script that sends this event to Google Analytics.<\/p>\n\n\n\n<h2>Conclusion<\/h2>\n\n\n\n<p>We have covered how you can add tracking to some of the popular ways forms are added. These methods would work perfectly if your site has a single form. If you happen to have more than one, you\u2019ll need to make some changes to the code.<\/p>\n\n\n\n<p>As you have seen, even the slightest change in approach requires for the entire code to change. So be cautious when making any changes and always test when implementing.<\/p>\n\n\n\n<p>That being said, if there are any other plugins or methods that you\u2019ll like for us to cover, comment below your suggestions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to our Google Analytics Goal Tracking guide! Today, we\u2019re going to go over how you can track form submissions [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Ultimate GA Goal Tracking Implementation Guide - Regex SEO Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.regexseo.com\/blog\/ultimate-ga-goal-tracking-implementation-guide\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ultimate GA Goal Tracking Implementation Guide - Regex SEO Blog\" \/>\n<meta property=\"og:description\" content=\"Welcome to our Google Analytics Goal Tracking guide! Today, we\u2019re going to go over how you can track form submissions [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.regexseo.com\/blog\/ultimate-ga-goal-tracking-implementation-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"Regex SEO Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-16T13:40:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-16T15:44:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/lh6.googleusercontent.com\/-Lruiym-kpBJlzp7QdOD_v9CKN2vGVZAoC4oMEL_R9gJr-eIR5jOBLFwOhZOLJYAX5PV9yCbuWjB-ZsNBsG9xfIEg9uiQTy2lXTq1-MBwAY_IkswCBnTJH4djq8lcOFxkWA-lITA\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\">\n\t<meta name=\"twitter:data1\" content=\"Shubh Sheth\">\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data2\" content=\"5 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.regexseo.com\/blog\/#website\",\"url\":\"https:\/\/www.regexseo.com\/blog\/\",\"name\":\"Regex SEO Blog\",\"description\":\"Your SEO, SEM and SMM Information Source\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.regexseo.com\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.regexseo.com\/blog\/ultimate-ga-goal-tracking-implementation-guide\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/lh6.googleusercontent.com\/-Lruiym-kpBJlzp7QdOD_v9CKN2vGVZAoC4oMEL_R9gJr-eIR5jOBLFwOhZOLJYAX5PV9yCbuWjB-ZsNBsG9xfIEg9uiQTy2lXTq1-MBwAY_IkswCBnTJH4djq8lcOFxkWA-lITA\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.regexseo.com\/blog\/ultimate-ga-goal-tracking-implementation-guide\/#webpage\",\"url\":\"https:\/\/www.regexseo.com\/blog\/ultimate-ga-goal-tracking-implementation-guide\/\",\"name\":\"Ultimate GA Goal Tracking Implementation Guide - Regex SEO Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.regexseo.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.regexseo.com\/blog\/ultimate-ga-goal-tracking-implementation-guide\/#primaryimage\"},\"datePublished\":\"2021-06-16T13:40:54+00:00\",\"dateModified\":\"2022-02-16T15:44:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.regexseo.com\/blog\/#\/schema\/person\/8f0c3e071fde34cc78700c9856d6d598\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.regexseo.com\/blog\/ultimate-ga-goal-tracking-implementation-guide\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.regexseo.com\/blog\/#\/schema\/person\/8f0c3e071fde34cc78700c9856d6d598\",\"name\":\"Shubh Sheth\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.regexseo.com\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.regexseo.com\/blog\/wp-content\/uploads\/2019\/06\/IMG-20181221-WA0001-e1561156485625-150x150.jpg\",\"caption\":\"Shubh Sheth\"},\"sameAs\":[\"https:\/\/www.regexseo.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.regexseo.com\/blog\/wp-json\/wp\/v2\/posts\/2370"}],"collection":[{"href":"https:\/\/www.regexseo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.regexseo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.regexseo.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.regexseo.com\/blog\/wp-json\/wp\/v2\/comments?post=2370"}],"version-history":[{"count":3,"href":"https:\/\/www.regexseo.com\/blog\/wp-json\/wp\/v2\/posts\/2370\/revisions"}],"predecessor-version":[{"id":2771,"href":"https:\/\/www.regexseo.com\/blog\/wp-json\/wp\/v2\/posts\/2370\/revisions\/2771"}],"wp:attachment":[{"href":"https:\/\/www.regexseo.com\/blog\/wp-json\/wp\/v2\/media?parent=2370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.regexseo.com\/blog\/wp-json\/wp\/v2\/categories?post=2370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.regexseo.com\/blog\/wp-json\/wp\/v2\/tags?post=2370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}