{"id":4392,"date":"2018-03-17T13:20:09","date_gmt":"2018-03-17T13:20:09","guid":{"rendered":"https:\/\/ampforwp.com\/tutorials\/?post_type=ht_kb&#038;p=4392"},"modified":"2020-05-07T11:30:29","modified_gmt":"2020-05-07T11:30:29","slug":"how-to-add-more-parameters-in-google-analytics-for-amp","status":"publish","type":"ht_kb","link":"https:\/\/ampforwp.com\/tutorials\/article\/how-to-add-more-parameters-in-google-analytics-for-amp\/","title":{"rendered":"How to add more parameters in Google Analytics for AMP"},"content":{"rendered":"\n<p>Let&#8217;s see how to add Advanced Google Analytics like page, event, social tracking in AMP.<\/p>\n\n\n\n<h3>1. Enable the Options<\/h3>\n\n\n\n<p>You will find this option in the<strong> WordPress Admin Area<\/strong> -&gt; <strong>AMP option panel<\/strong> -&gt;<strong> Settings<\/strong> -&gt; <strong>Analytics<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-1.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1284\" height=\"414\" src=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-1.png\" alt=\"\" class=\"wp-image-10535\" srcset=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-1.png 1284w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-1-300x97.png 300w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-1-768x248.png 768w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-1-1024x330.png 1024w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-1-50x16.png 50w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-1-60x19.png 60w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-1-100x32.png 100w\" sizes=\"(max-width: 1284px) 100vw, 1284px\" \/><\/a><\/figure>\n\n\n\n<ul><li><strong>Google Analytics:<\/strong> First enable the Google Analytics option and Enter the Analytics ID.<\/li><\/ul>\n\n\n\n<h3>2. Add the Advanced Analytics Code<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-2.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1317\" height=\"627\" src=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-2.png\" alt=\"\" class=\"wp-image-10538\" srcset=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-2.png 1317w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-2-300x143.png 300w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-2-768x366.png 768w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-2-1024x488.png 1024w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-2-50x24.png 50w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-2-60x29.png 60w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2018\/03\/google-analytics-2-100x48.png 100w\" sizes=\"(max-width: 1317px) 100vw, 1317px\" \/><\/a><\/figure>\n\n\n\n<ul><li><strong>Advanced Google Analytics:<\/strong> 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 &#8220;UA-xxxxxxx-x&#8221; with your Google Analytics ID.<\/li><li>Enter other tracking code in place of &#8220;\/\/ Enter your Advanced Analytics code here&#8221;.<\/li><\/ul>\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;}\">&quot;trackEvent&quot;: {\n        &quot;selector&quot;: &quot;#event-test&quot;,\n        &quot;on&quot;: &quot;click&quot;,\n        &quot;request&quot;: &quot;event&quot;,\n        &quot;vars&quot;: {\n          &quot;eventCategory&quot;: &quot;ui-components&quot;,\n          &quot;eventAction&quot;: &quot;click&quot;\n        }\n      }<\/pre><\/div>\n\n\n\n<p>You can insert title, URL, and id as {title}, {url} and {id} respectively.<\/p>\n\n\n\n<p><strong>For example:<\/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;}\">&quot;url&quot;: &quot;{url}&quot;,\n&quot;title&quot;: &quot;{title}&quot;,\n&quot;id&quot;: &quot;{id}&quot;<\/pre><\/div>\n\n\n\n<p>URL, Title and post ID can be passed shown below.<\/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;}\">&quot;trackEvent&quot;: {\n        &quot;selector&quot;: &quot;#event-test&quot;,\n        &quot;on&quot;: &quot;click&quot;,\n        &quot;request&quot;: &quot;event&quot;,\n        &quot;vars&quot;: {\n          &quot;eventCategory&quot;: &quot;ui-components&quot;,\n          &quot;eventAction&quot;: &quot;click&quot;,\n          &quot;url&quot;: &quot;{url}&quot;,\n          &quot;title&quot;: &quot;{title}&quot;,\n          &quot;id&quot;: &quot;{id}&quot;,\n          &quot;author-id&quot;: &quot;{author_id}&quot;,\n          &quot;author-name&quot;: &quot;{author_name}&quot;,\n          &quot;category&quot;: &quot;{category}&quot;,\n          &quot;published-at&quot;: &quot;{published_at}&quot;,\n          &quot;tags&quot;:&quot;{tags}&quot;,\n          &quot;seo-score&quot;:&quot;{seo_score}&quot;,\n          &quot;focus-keyword&quot;:&quot;{focus_keyword}&quot;\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><strong>Note: This is just an example code used only for demonstration purpose.&nbsp;<\/strong><\/p>\n\n\n\n<p>I hope this tutorial helps you to successfully add the Analytics on your site and If you encounter any issue you can reach us for the help <a href=\"https:\/\/ampforwp.com\/support\/\">here<\/a>.<\/p>\n\n\n\n<p>Google Documentation for AMP analytics:&nbsp;<a href=\"https:\/\/developers.google.com\/analytics\/devguides\/collection\/amp-analytics\/\">https:\/\/developers.google.com\/analytics\/devguides\/collection\/amp-analytics\/<\/a><\/p>\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><\/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&#8217;s see how to add Advanced Google Analytics like page, event, social tracking in AMP. 1. Enable the Options You will find this option in the WordPress Admin Area -&gt; AMP option panel -&gt; Settings -&gt; Analytics Google Analytics: First enable the Google Analytics option and Enter the Analytics ID&#8230;.<\/p>\n","protected":false},"author":5,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":[],"ht-kb-category":[34],"ht-kb-tag":[25,125,126],"_links":{"self":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/4392"}],"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\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/comments?post=4392"}],"version-history":[{"count":35,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/4392\/revisions"}],"predecessor-version":[{"id":17279,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/4392\/revisions\/17279"}],"wp:attachment":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/media?parent=4392"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb-category?post=4392"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb-tag?post=4392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}