{"id":41775,"date":"2025-09-01T19:08:43","date_gmt":"2025-09-01T16:08:43","guid":{"rendered":"https:\/\/coma.lv\/2025\/09\/01\/how-to-add-event-tracking-in-google-analytics\/"},"modified":"2025-09-01T19:08:43","modified_gmt":"2025-09-01T16:08:43","slug":"how-to-add-event-tracking-in-google-analytics","status":"publish","type":"post","link":"https:\/\/coma.lv\/en\/2025\/09\/01\/how-to-add-event-tracking-in-google-analytics\/","title":{"rendered":"How to Add Event Tracking in Google Analytics"},"content":{"rendered":"\n<p style=\"text-align: left;\">Would you like to track user activity while they are still on your site? You can track page views, referral sources, the time a user spends on a page and much more simply by installing Google Analytics, but for deeper results you will need event tracking. In this article we will show you how to add Google Analytics event tracking in WordPress.<\/p>\n<h2 style=\"text-align: left;\">What Is Event Tracking<\/h2>\n<p style=\"text-align: left;\">Event tracking lets you measure user actions on your site. These actions can be clicks on buttons, video plays, file downloads, form submissions and so on. Say you added a video to a product page and want to find out how effective it is in terms of conversion. Event tracking lets you find out how many users played the video. Another example is AJAX-based form submissions. If you use Gravity Forms or another contact plugin, submitting a form does not turn into a new page view. Using event tracking, you can see how users interacted with the form. The same applies to file downloads: you can track how many users downloaded a file using event tracking, and even which button on the page was clicked most often. Event tracking differs from link tracking in Google Analytics. All of this lets you see how people behave on your site. This in turn lets you choose the right strategy for sales and conversions based on user preferences.<\/p>\n<h2 style=\"text-align: left;\">Getting Started<\/h2>\n<p style=\"text-align: left;\">Before you start, you will need to set up and install Google Analytics on your site.<\/p>\n<p style=\"text-align: left;\"><strong data-start=\"2481\" data-end=\"2512\">Important:<\/strong> In 2023 Google fully shut down <strong data-start=\"2551\" data-end=\"2574\">Universal Analytics<\/strong> and moved all users to <strong data-start=\"2607\" data-end=\"2635\">Google Analytics 4 (GA4)<\/strong>. The old <code data-start=\"2648\" data-end=\"2662\">analytics.js<\/code> code no longer works.<\/p>\n<p style=\"text-align: left;\">If your site&#8217;s code still contains something like:<\/p>\n<pre><code>\n&lt;script&gt;\n  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n  })(window,document,'script','https:\/\/www.google-analytics.com\/analytics.js','ga');\n\n  ga('create', 'UA-XXXXX-Y', 'auto');\n  ga('send', 'pageview');\n&lt;\/script&gt;\n<\/code><\/pre>\n<div class=\"contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary\" style=\"text-align: left;\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\">\u2014 this is <strong data-start=\"3161\" data-end=\"3199\">outdated Universal Analytics code<\/strong>, and it no longer collects data.<\/div>\n<\/div>\n<p style=\"text-align: left;\">Instead, <strong data-start=\"2435\" data-end=\"2457\">Google Analytics 4<\/strong> is now used on all sites. You can install the code directly or through Google Tag Manager.<\/p>\n<p style=\"text-align: left;\" data-start=\"2522\" data-end=\"2549\">Example of the basic GA4 code:<\/p>\n<pre><code>\n&lt;script async src=\"https:\/\/www.googletagmanager.com\/gtag\/js?id=G-XXXXXXXXXX\"&gt;&lt;\/script&gt;\n&lt;script&gt;\n  window.dataLayer = window.dataLayer || [];\n  function gtag(){dataLayer.push(arguments);}\n  gtag('js', new Date());\n\n  gtag('config', 'G-XXXXXXXXXX');\n&lt;\/script&gt;\n<\/code><\/pre>\n<h2 style=\"text-align: left;\">Creating Your Own Event in Google Analytics<\/h2>\n<p style=\"text-align: left;\">Go to your GA4 profile and click the <strong data-start=\"821\" data-end=\"830\">Admin<\/strong> link at the bottom of the left panel. If you have several sites, make sure you are viewing the dashboard of the site you need.<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36161 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2016\/12\/Ekranuznemums-2025-09-17-052319.png\" alt=\"WordPress\" width=\"338\" height=\"530\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2016\/12\/Ekranuznemums-2025-09-17-052319.png 338w, https:\/\/coma.lv\/wp-content\/uploads\/2016\/12\/Ekranuznemums-2025-09-17-052319-191x300.png 191w\" sizes=\"auto, (max-width: 338px) 100vw, 338px\" \/><\/p>\n<p style=\"text-align: left;\">In the <strong data-start=\"264\" data-end=\"272\">Data display<\/strong> section choose <strong data-start=\"282\" data-end=\"292\">Events<\/strong>. Here you can create your own events or edit existing ones.<\/p>\n<p style=\"text-align: left;\" data-start=\"177\" data-end=\"373\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36164 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-17-053017.jpg\" alt=\"WordPress\" width=\"920\" height=\"298\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-17-053017.jpg 920w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-17-053017-300x97.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-17-053017-768x249.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-17-053017-705x228.jpg 705w\" sizes=\"auto, (max-width: 920px) 100vw, 920px\" \/><\/p>\n<p style=\"text-align: left;\">Click the <strong data-start=\"994\" data-end=\"1010\">Create Event<\/strong> button and set the conditions for the new event. For example, if you want to track a form submission, enter the event name <em>form_submit<\/em> and specify the parameters that will be used to track this action on the site.<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36167 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-17-055502.jpg\" alt=\"WordPress\" width=\"817\" height=\"555\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-17-055502.jpg 817w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-17-055502-300x204.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-17-055502-768x522.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-17-055502-705x479.jpg 705w\" sizes=\"auto, (max-width: 817px) 100vw, 817px\" \/><\/p>\n<p style=\"text-align: left;\">After the event is created and has been recorded at least once, it will appear in the <strong data-start=\"248\" data-end=\"258\">Events<\/strong> section on the <strong data-start=\"270\" data-end=\"287\">Recent events<\/strong> tab. Here you can mark it as a <strong data-start=\"338\" data-end=\"351\">Key Event<\/strong> (this is what used to be called a <em data-start=\"383\" data-end=\"395\">conversion<\/em>). After that the event will be shown on a separate <strong data-start=\"458\" data-end=\"472\">Key events<\/strong> tab. If necessary, you can also mark the event as <strong data-start=\"525\" data-end=\"553\">NPA (Non-Personalized Ads)<\/strong> so that it is not used for ad personalization.<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36171 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-18-000326.jpg\" alt=\"WordPress\" width=\"1368\" height=\"481\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-18-000326.jpg 1368w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-18-000326-300x105.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-18-000326-1030x362.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-18-000326-768x270.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-18-000326-705x248.jpg 705w\" sizes=\"auto, (max-width: 1368px) 100vw, 1368px\" \/><\/p>\n<h2 style=\"text-align: left;\">Adding onClick Event Tracking<\/h2>\n<p style=\"text-align: left;\">The simplest and perhaps fastest way to add Google Analytics event tracking is to use the <code data-start=\"3901\" data-end=\"3910\">onClick<\/code> attribute. This method simply sends an event to Google Analytics when a user clicks an element. In this example we will track users who click a book download link. We will add an onClick parameter to the download link using this format.<\/p>\n<pre><code>\nonClick=\"gtag('event', 'download', {\n  content_type: 'ebook',\n  content_title: 'Free Ebook'\n});\"\n<\/code><\/pre>\n<p style=\"text-align: left;\">You will need to replace the type, name and label with those that match the conditions of your event. In the end the book download link will look like this:<\/p>\n<pre><code>\n&lt;a onClick=\"gtag('event', 'download', {\n  content_type: 'ebook',\n  content_title: 'Free Marketing Ebook'\n});\" \nhref=\"http:\/\/example.com\/wp-content\/uploads\/2025\/01\/free-ebook.pdf\"&gt;\n  Download Free Ebook\n&lt;\/a&gt;\n<\/code><\/pre>\n<p style=\"text-align: left;\">When a user clicks the link, an event will be sent to Google Analytics.<\/p>\n<p style=\"text-align: left;\"><strong>Important:<\/strong> in WordPress, some themes, plugins or security settings may block inline <code data-start=\"1063\" data-end=\"1072\">onClick<\/code>. To reliably track such clicks and avoid problems with blocking of inline <code data-start=\"460\" data-end=\"469\">onClick<\/code>, you can use<strong data-start=\"471\" data-end=\"515\"> Google Tag Manager<\/strong>, which we will cover next.<\/p>\n<h2 style=\"text-align: left;\">Adding Event Tracking with Google Tag Manager<\/h2>\n<p style=\"text-align: left;\"><a href=\"https:\/\/tagmanager.google.com\/\" target=\"_blank\" rel=\"noopener\">Google Tag Manager<\/a> is an online tool that lets you add various tracking codes as tags. You can use it to create tags for tracking events in your Google Analytics profile. The main advantage of using Google Tag Manager is that you will not need to add code to your site manually and you can manage all your tags from one place.<\/p>\n<p style=\"text-align: left;\" data-start=\"361\" data-end=\"513\">*If your site already has the GA4 tracking code inserted, you do not have to remove it, but keep in mind that the same events may be duplicated.<\/p>\n<p style=\"text-align: left;\">Once you have successfully added the Google Analytics tag to the tag manager, the next step is to create a new trigger. In this article we will use form submission tracking as the event. Click <strong data-start=\"737\" data-end=\"749\">Triggers<\/strong> in the tag manager and then click the <strong data-start=\"795\" data-end=\"802\">New<\/strong> button.<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36179 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-011235.jpg\" alt=\"WordPress\" width=\"1899\" height=\"324\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-011235.jpg 1899w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-011235-300x51.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-011235-1030x176.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-011235-768x131.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-011235-1536x262.jpg 1536w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-011235-1500x256.jpg 1500w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-011235-705x120.jpg 705w\" sizes=\"auto, (max-width: 1899px) 100vw, 1899px\" \/><\/p>\n<p style=\"text-align: left;\">You will land in the setup wizard, where you need to choose the event type \u2014 for example, <strong data-start=\"5668\" data-end=\"5687\">Form Submission<\/strong>.<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36182 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-011523.jpg\" alt=\"WordPress\" width=\"663\" height=\"487\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-011523.jpg 663w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-011523-300x220.jpg 300w\" sizes=\"auto, (max-width: 663px) 100vw, 663px\" \/><\/p>\n<p style=\"text-align: left;\">In the trigger settings you can choose whether to fire it for all forms or only for some. If you have more than one form on the page and want to track a specific one, set up a filter by form ID or class. To do this, in the <strong data-start=\"294\" data-end=\"307\">Variables<\/strong> section click <strong data-start=\"316\" data-end=\"329\">Configure<\/strong> and enable the built-in variables <strong data-start=\"321\" data-end=\"351\">Form ID <\/strong>and\/or <strong data-start=\"321\" data-end=\"351\">Form Classes <\/strong>(and, if necessary, other form variables). In the trigger condition use, for example, <em>Form ID equals contact_form_1<\/em> or <em>Form Classes contains newsletter-form<\/em>, so that the tag fires only for the form you need.<\/p>\n<p style=\"text-align: left;\" data-start=\"5692\" data-end=\"5894\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36185 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-012919.jpg\" alt=\"WordPress\" width=\"1905\" height=\"394\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-012919.jpg 1905w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-012919-300x62.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-012919-1030x213.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-012919-768x159.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-012919-1536x318.jpg 1536w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-012919-1500x310.jpg 1500w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-012919-705x146.jpg 705w\" sizes=\"auto, (max-width: 1905px) 100vw, 1905px\" \/><\/p>\n<p style=\"text-align: left;\" data-start=\"5692\" data-end=\"5894\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36188 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-013001.jpg\" alt=\"WordPress\" width=\"764\" height=\"504\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-013001.jpg 764w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-013001-300x198.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-013001-705x465.jpg 705w\" sizes=\"auto, (max-width: 764px) 100vw, 764px\" \/><\/p>\n<p style=\"text-align: left;\" data-start=\"5692\" data-end=\"5894\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36191 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-013123.jpg\" alt=\"WordPress\" width=\"1124\" height=\"507\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-013123.jpg 1124w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-013123-300x135.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-013123-1030x465.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-013123-768x346.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-013123-705x318.jpg 705w\" sizes=\"auto, (max-width: 1124px) 100vw, 1124px\" \/><\/p>\n<p style=\"text-align: left;\"><em data-start=\"79\" data-end=\"92\">Note:<\/em> for forms that use AJAX, the standard Form Submission trigger often does not fire. In such cases you can use <strong data-start=\"263\" data-end=\"279\">Custom Event<\/strong> for accurate tracking of a specific form. For ordinary forms, you can select a specific form by the ID or class of the <code data-start=\"352\" data-end=\"360\">&lt;form&gt;<\/code>, specifying the corresponding condition in the trigger. For Contact Form 7 and other forms whose <code data-start=\"451\" data-end=\"459\">&lt;form&gt;<\/code> has no ID or unique class, it is more reliable to use the form&#8217;s <strong data-start=\"526\" data-end=\"536\">action<\/strong> attribute. In GTM add a condition using the <strong data-start=\"589\" data-end=\"605\">Form Element<\/strong> variable with a <strong data-start=\"618\" data-end=\"642\" data-is-only-node=\"\">matches CSS selector<\/strong> check and specify a value such as <code data-start=\"673\" data-end=\"717\">form[action=\"\/contacts\/#wpcf7-f42-p43-o1\"]<\/code>.<\/p>\n<p style=\"text-align: left;\" data-start=\"81\" data-end=\"765\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36220 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-050004.jpg\" alt=\"WordPress\" width=\"1124\" height=\"557\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-050004.jpg 1124w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-050004-300x149.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-050004-1030x510.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-050004-768x381.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-050004-705x349.jpg 705w\" sizes=\"auto, (max-width: 1124px) 100vw, 1124px\" \/><\/p>\n<p style=\"text-align: left;\">You can find out the form&#8217;s ID, class or action through the browser inspector by looking at the <code data-start=\"521\" data-end=\"525\">id<\/code>, <code data-start=\"521\" data-end=\"525\">class<\/code> or <code data-start=\"521\" data-end=\"525\">action<\/code> attribute of the <code data-start=\"565\" data-end=\"573\">&lt;form&gt;<\/code> tag.<\/p>\n<p style=\"text-align: left;\" data-start=\"5692\" data-end=\"5894\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36217 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-040743.jpg\" alt=\"WordPress\" width=\"1085\" height=\"286\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-040743.jpg 1085w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-040743-300x79.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-040743-1030x272.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-040743-768x202.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-040743-705x186.jpg 705w\" sizes=\"auto, (max-width: 1085px) 100vw, 1085px\" \/><\/p>\n<p style=\"text-align: left;\">After that, create a new tag. In the tag manager click <strong data-start=\"5957\" data-end=\"5965\">Tags<\/strong> and then the <strong data-start=\"5984\" data-end=\"5991\">New<\/strong> button.<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36197 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015207.jpg\" alt=\"WordPress\" width=\"1900\" height=\"328\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015207.jpg 1900w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015207-300x52.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015207-1030x178.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015207-768x133.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015207-1536x265.jpg 1536w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015207-1500x259.jpg 1500w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015207-705x122.jpg 705w\" sizes=\"auto, (max-width: 1900px) 100vw, 1900px\" \/><\/p>\n<p style=\"text-align: left;\">Choose <strong data-start=\"6002\" data-end=\"6033\">Google Analytics: GA4 Event<\/strong> as the tag type.<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36200 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015921.jpg\" alt=\"WordPress\" width=\"775\" height=\"433\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015921.jpg 775w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015921-300x168.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015921-768x429.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-015921-705x394.jpg 705w\" sizes=\"auto, (max-width: 775px) 100vw, 775px\" \/><\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36203 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-020004.jpg\" alt=\"WordPress\" width=\"792\" height=\"326\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-020004.jpg 792w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-020004-300x123.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-020004-768x316.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-020004-705x290.jpg 705w\" sizes=\"auto, (max-width: 792px) 100vw, 792px\" \/><\/p>\n<p style=\"text-align: left;\" data-end=\"306\">If you have already inserted the Google tag on your site directly, you do not need to create a separate Google tag in GTM at this step. It is enough to create only the <strong data-start=\"454\" data-end=\"471\">GA4 Event <\/strong>for the event you need.<\/p>\n<p style=\"text-align: left;\">Specify the Google Analytics tracking ID (G-XXXXXXX). You can get it from your Google Analytics profile (go to <strong data-start=\"129\" data-end=\"188\">Admin \u2192 Data collection and modification \u2192 Data Streams<\/strong>, choose your web stream and copy the <strong data-start=\"226\" data-end=\"244\">Measurement ID<\/strong> in the upper right corner of the page).<\/p>\n<p style=\"text-align: left;\">Then set the event name and parameters: specify the <strong data-start=\"221\" data-end=\"235\">Event Name<\/strong>, and add the event parameters one at a time via <strong data-start=\"284\" data-end=\"301\">Add parameter<\/strong>, entering values such as <code data-start=\"328\" data-end=\"349\">form_type = contact<\/code>, <code data-start=\"351\" data-end=\"379\">form_name = contact_form_1<\/code>, <code data-start=\"381\" data-end=\"399\">submitted = true<\/code>.<\/p>\n<p style=\"text-align: left;\" data-start=\"6059\" data-end=\"6148\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36207 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024718.jpg\" alt=\"WordPress\" width=\"1122\" height=\"577\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024718.jpg 1122w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024718-300x154.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024718-1030x530.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024718-768x395.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024718-705x363.jpg 705w\" sizes=\"auto, (max-width: 1122px) 100vw, 1122px\" \/><\/p>\n<p style=\"text-align: left;\">For a form submission it will look like this:<\/p>\n<p style=\"text-align: left;\" data-start=\"451\" data-end=\"482\"><strong data-start=\"451\" data-end=\"466\">Event Name:<\/strong> <code data-start=\"467\" data-end=\"480\">form_submit<\/code><\/p>\n<p style=\"text-align: left;\" data-start=\"484\" data-end=\"507\"><strong data-start=\"484\" data-end=\"505\">Event Parameters:<\/strong><\/p>\n<ul style=\"text-align: left;\" data-start=\"508\" data-end=\"589\">\n<li data-start=\"508\" data-end=\"533\">\n<p data-start=\"510\" data-end=\"533\"><code data-start=\"510\" data-end=\"531\">form_type = contact<\/code><\/p>\n<\/li>\n<li data-start=\"534\" data-end=\"566\">\n<p data-start=\"536\" data-end=\"566\"><code data-start=\"536\" data-end=\"564\">form_name = contact_form_1<\/code><\/p>\n<\/li>\n<li data-start=\"567\" data-end=\"589\">\n<p data-start=\"569\" data-end=\"589\"><code data-start=\"569\" data-end=\"587\">submitted = true<\/code><\/p>\n<\/li>\n<\/ul>\n<p style=\"text-align: left;\">*If the tag configuration shows the message \u201cNo Google tag found in this container\u201d, this is normal if you have already installed the Google tag directly on the site. In this case the GA4 Event tag will work without a separate Configuration tag in GTM.<\/p>\n<p style=\"text-align: left;\">In the next step, choose the trigger you created earlier.<\/p>\n<p style=\"text-align: left;\" data-start=\"6278\" data-end=\"6340\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36210 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024918.jpg\" alt=\"WordPress\" width=\"1173\" height=\"379\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024918.jpg 1173w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024918-300x97.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024918-1030x333.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024918-768x248.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024918-705x228.jpg 705w\" sizes=\"auto, (max-width: 1173px) 100vw, 1173px\" \/><\/p>\n<p style=\"text-align: left;\" data-start=\"6278\" data-end=\"6340\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36213 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024935.jpg\" alt=\"WordPress\" width=\"909\" height=\"360\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024935.jpg 909w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024935-300x119.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024935-768x304.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-19-024935-705x279.jpg 705w\" sizes=\"auto, (max-width: 909px) 100vw, 909px\" \/><\/p>\n<p style=\"text-align: left;\">Finally, click the <strong data-start=\"6370\" data-end=\"6384\">Save<\/strong> button to save the tag. In the window that appears, enter a name for the tag and click <strong data-start=\"202\" data-end=\"210\">Save<\/strong> again. The tag will appear in the workspace. For the changes to take effect on the site, click <strong data-start=\"299\" data-end=\"309\">Submit<\/strong> in the upper right corner, enter a version name (optionally add a description) and confirm the publication.<\/p>\n<p style=\"text-align: left;\">That&#8217;s it. Now go to your site and submit the form, then go to <strong data-start=\"6556\" data-end=\"6589\">Reports \u2192 Engagement \u2192 Events<\/strong> in your Analytics profile, and you will see your event recorded and tracked.<\/p>\n<p style=\"text-align: left;\">Using the tag manager, you can create different types of events and manage them centrally. It will also save you from editing your WordPress templates or adding code manually.<\/p>\n<hr \/>\n<p style=\"text-align: left;\"><em>Our specialization is WordPress website development and maintenance. Contact us for a free consultation \u2014 <a href=\"mailto:vadim@coma.lv\">vadim@coma.lv<\/a>, <a href=\"tel:+37129394520\">+371 29394520<\/a><\/em><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>Would you like to track user activity while they are still on your site? You can track page views, referral sources, the time a user spends on a page and much more simply by installing Google Analytics, but for deeper results you will need event tracking. In this article we will show you how to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":37668,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1407,1225],"tags":[],"class_list":["post-41775","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-wordpress"],"_links":{"self":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/comments?post=41775"}],"version-history":[{"count":0,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41775\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media\/37668"}],"wp:attachment":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media?parent=41775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/categories?post=41775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/tags?post=41775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}