{"id":10936,"date":"2019-06-10T11:25:55","date_gmt":"2019-06-10T11:25:55","guid":{"rendered":"https:\/\/ampforwp.com\/tutorials\/?post_type=ht_kb&#038;p=10936"},"modified":"2020-05-08T06:39:57","modified_gmt":"2020-05-08T06:39:57","slug":"how-to-track-a-click-event-in-gtm-amp","status":"publish","type":"ht_kb","link":"https:\/\/ampforwp.com\/tutorials\/article\/how-to-track-a-click-event-in-gtm-amp\/","title":{"rendered":"How to track a click event in GTM AMP"},"content":{"rendered":"\n<p>Let\u2019s see how to add Advanced Google Analytics like page, event, social tracking in AMP.<\/p>\n\n\n\n<p>You will find this option in the<strong>&nbsp;WordPress Admin Area<\/strong>&nbsp;-&gt;&nbsp;<strong>AMP option panel<\/strong>&nbsp;-&gt;<strong>&nbsp;Settings<\/strong>&nbsp;-&gt;&nbsp;<strong>Analytics<\/strong><\/p>\n\n\n\n<ul><li><strong>Google Tag Manager:<\/strong>&nbsp;First enable the Google Tag Manager option and Enter the Analytics ID.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"494\" src=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/1-4-1024x494.png\" alt=\"\" class=\"wp-image-14296\" srcset=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/1-4-1024x494.png 1024w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/1-4-300x145.png 300w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/1-4-768x371.png 768w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/1-4-50x24.png 50w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/1-4-60x29.png 60w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/1-4-100x48.png 100w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/1-4.png 1310w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul><li><strong>Advanced Google Analytics:<\/strong>&nbsp;Enable the Advanced Google Analytics option. As you can see there is a JavaScript editor to add the Analytics code in JSON format.<\/li><li>Change the \u201c&lt;GA_MEASUREMENT_ID&gt;\u201d with your Google Analytics ID.<\/li><li>Enter other tracking code in place of \u201c\/\/ Enter your Advanced Analytics code here\u201d.<\/li><\/ul>\n\n\n\n<h4 id=\"measure_events\">Measure events<\/h4>\n\n\n\n<p>Use&nbsp;<a href=\"https:\/\/www.ampproject.org\/docs\/reference\/components\/amp-analytics#triggers\"><code>triggers<\/code><\/a>&nbsp;with defined values to measure events in AMP pages. These properties are used in a trigger configuration:<\/p>\n\n\n\n<ul><li><a href=\"https:\/\/www.ampproject.org\/docs\/reference\/components\/amp-analytics#element-selector\"><code>selector<\/code><\/a>: a CSS selector to specify a target element.<\/li><li><code>on<\/code>: specifies the type of event.<\/li><li><code>vars<\/code>: specify the type of event in&nbsp;<code>event_name<\/code>, and add additional parameters as necessary.<\/li><\/ul>\n\n\n\n<p>This example demonstrates how to set up a basic Google Analytics event. Create a trigger called &#8220;<strong>button<\/strong>&#8221; that will fire when an element with an ID value of &#8220;<strong>the-button<\/strong>&#8221; is clicked. This trigger will send an&nbsp;<code>event_name<\/code>&nbsp;value of &#8220;<strong>login<\/strong>&#8221; and a&nbsp;<code>method<\/code>&nbsp;value of &#8220;<strong>Google<\/strong>&#8221; to Google Analytics:<\/p>\n\n\n\n<p><strong>Example code:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text\/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;PHP&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;php&quot;}\">{\n      &quot;vars&quot;: {\n        &quot;gtag_id&quot;: &quot;&quot;,\n        &quot;config&quot;: {\n         &quot;&quot;: { &quot;groups&quot;: &quot;default&quot; }\n        }\n      },\n      &quot;triggers&quot;: {\n        &quot;button&quot;: {\n          &quot;selector&quot;: &quot;#the-button&quot;,\n          &quot;on&quot;: &quot;click&quot;,\n          &quot;vars&quot;: {\n            &quot;event_name&quot;: &quot;login&quot;,\n            &quot;method&quot;: &quot;Google&quot;\n          }\n        }\n      }\n    }<\/pre><\/div>\n\n\n\n<p><a href=\"https:\/\/support.google.com\/analytics\/answer\/1033068\">Google Analytics Events<\/a>&nbsp;are a category of events specific to Google Analytics that are commonly used to build reports on campaigns. These values can be specified in the vars block with&nbsp;<code>event_category<\/code>,&nbsp;<code>event_label<\/code>, and&nbsp;<code>value<\/code>&nbsp;parameters:\n\n<\/p>\n\n\n\n<p><strong>Example code:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text\/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;PHP&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;php&quot;}\">{\n      &quot;vars&quot;: {\n        &quot;gtag_id&quot;: &quot;&quot;,\n        &quot;config&quot;: {\n          &quot;&quot;: { &quot;groups&quot;: &quot;default&quot; }\n        }\n      },\n      &quot;triggers&quot;: {\n        &quot;button&quot;: {\n          &quot;selector&quot;: &quot;#login&quot;,\n          &quot;on&quot;: &quot;click&quot;,\n          &quot;vars&quot;: {\n            &quot;event_name&quot;: &quot;login&quot;,\n            &quot;method&quot;: &quot;Google&quot;\n          }\n        }\n      }\n    }<\/pre><\/div>\n\n\n\n<h4 id=\"modify_parameters\">Modify parameters<\/h4>\n\n\n\n<p>To override default Google Analytics parameters or add new parameters, add the desired values to the&nbsp;<code>parameter<\/code>&nbsp;section of your&nbsp;<code>config<\/code>&nbsp;block. This example overrides the default pageview and event values for&nbsp;<code>page_title<\/code>&nbsp;and&nbsp;<code>page_location<\/code>:<\/p>\n\n\n\n<p><strong>Example code:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text\/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;PHP&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;php&quot;}\">{\n  &quot;vars&quot; : {\n    &quot;gtag_id&quot;: &quot;&quot;,\n    &quot;config&quot; : {\n      &quot;&quot;: {\n        &quot;groups&quot;: &quot;default&quot;,\n        &quot;page_title&quot;: &quot;Beethoven symphonies&quot;,\n        &quot;page_location&quot;: &quot;https:\/\/www.example.com\/beethoven.html&quot;\n      }\n    }\n  }\n}<\/pre><\/div>\n\n\n\n<p>Before adding this two variable make sure you need to activate <a href=\"https:\/\/wordpress.org\/plugins\/wordpress-seo\/\">Yoast SEO plugin.<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-1.png\"><img decoding=\"async\" loading=\"lazy\" width=\"445\" height=\"63\" src=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-1.png\" alt=\"\" class=\"wp-image-10801\" srcset=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-1.png 445w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-1-300x42.png 300w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-1-50x7.png 50w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-1-60x8.png 60w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-1-100x14.png 100w\" sizes=\"(max-width: 445px) 100vw, 445px\" \/><\/a><\/figure>\n\n\n\n<p>After adding another tracking code, your&nbsp;code should look like this:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-2.png\"><img decoding=\"async\" loading=\"lazy\" width=\"836\" height=\"518\" src=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-2.png\" alt=\"\" class=\"wp-image-10804\" srcset=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-2.png 836w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-2-300x186.png 300w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-2-768x476.png 768w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-2-50x31.png 50w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-2-60x37.png 60w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/variable-2-100x62.png 100w\" sizes=\"(max-width: 836px) 100vw, 836px\" \/><\/a><\/figure>\n\n\n\n<p>If you want to check Google Analytics Event then you need to follow the below Screenshot.<\/p>\n\n\n\n<p>You will find this option first log in to <strong>Google Analytics<\/strong> -&gt; <strong>Reporting<\/strong> -&gt; <strong>behavior<\/strong> -&gt; <strong>Events<\/strong>  -&gt; Here is a list of  <strong>Events Category<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"450\" src=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/4-1-1024x450.png\" alt=\"\" class=\"wp-image-14399\" srcset=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/4-1-1024x450.png 1024w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/4-1-300x132.png 300w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/4-1-768x337.png 768w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/4-1-50x22.png 50w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/4-1-60x26.png 60w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/4-1-100x44.png 100w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/09\/4-1.png 1710w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>That\u2019s it for this tutorial!<\/strong><\/p>\n\n\n\n<p>We hope it helped you. If you have any feedback or questions, then please share them in the comments section below.<\/p>\n\n\n\n<p><br><\/p>\n<div id=\"div-1\" class=\"hkb-feedback\">\n\t\t\t<strong class=\"ht-mobile-exit__title\">Ask your Questions Directly!<\/strong><br>\n\t\t\t<div class=\"hkb_widget_exit__content\" style=\"font-size: 14px;\">If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!<\/div>\n\t\t\t<a href=\"https:\/\/ampforwp.com\/support\/#contact\" id=\"button\" target=\"_blank\" rel=\"noopener noreferrer\"><button>Yes, I have a Question<\/button><\/a>\n\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>Let\u2019s see how to add Advanced Google Analytics like page, event, social tracking in AMP. You will find this option in the&nbsp;WordPress Admin Area&nbsp;-&gt;&nbsp;AMP option panel&nbsp;-&gt;&nbsp;Settings&nbsp;-&gt;&nbsp;Analytics Google Tag Manager:&nbsp;First enable the Google Tag Manager option and Enter the Analytics ID. Advanced Google Analytics:&nbsp;Enable the Advanced Google Analytics option. As you&#8230;<\/p>\n","protected":false},"author":18,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":[],"ht-kb-category":[34],"ht-kb-tag":[],"_links":{"self":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/10936"}],"collection":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/comments?post=10936"}],"version-history":[{"count":30,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/10936\/revisions"}],"predecessor-version":[{"id":17296,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/10936\/revisions\/17296"}],"wp:attachment":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/media?parent=10936"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb-category?post=10936"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb-tag?post=10936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}