<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Conversioner &#187; AMP Project</title>
	<atom:link href="https://www.conversioner.com/tag/amp-project/feed" rel="self" type="application/rss+xml" />
	<link>https://www.conversioner.com</link>
	<description>Emotional Conversion Optimization</description>
	<lastBuildDate>Sun, 28 Nov 2021 06:47:48 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.7.39</generator>
	<item>
		<title>Implementing Google Analytics in AMP Websites Using Google Tag Manager</title>
		<link>https://www.conversioner.com/blog/google-analytics-amp-website-google-tag-manager</link>
		<comments>https://www.conversioner.com/blog/google-analytics-amp-website-google-tag-manager#comments</comments>
		<pubDate>Sun, 27 Nov 2016 12:07:11 +0000</pubDate>
		<dc:creator><![CDATA[Shuki Mann]]></dc:creator>
				<category><![CDATA[Conversion Optimization Blog]]></category>
		<category><![CDATA[AMP Project]]></category>
		<category><![CDATA[Analytics Events]]></category>
		<category><![CDATA[Google analytics]]></category>
		<category><![CDATA[Google Tag Manager]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">https://www.conversioner.com/?p=4875</guid>
		<description><![CDATA[<p>Google AMP Project is a very hot topic in these days. Today I&#8217;m going to show you how to implement Google Analytics (or &#8220;AMP Analytics&#8221;) in your website, and how to install it through Google Tag Manager. Before we get started, here is a list of topics we will be discussing: What is AMP Setting&#8230;</p><p>The post <a href="https://www.conversioner.com/blog/google-analytics-amp-website-google-tag-manager">Implementing Google Analytics in AMP Websites Using Google Tag Manager</a> appeared first on <a href="https://www.conversioner.com">Conversioner</a>.</p>]]></description>
				<content:encoded><![CDATA[<div  class="l-subsection"><div class="l-subsection-h"><div class="l-subsection-hh g-html i-cf"><p dir="ltr">Google AMP Project is a very hot topic in these days.</p>
<p dir="ltr">Today I&#8217;m going to show you how to implement Google Analytics (or &#8220;AMP Analytics&#8221;) in your website, and how to install it through Google Tag Manager.</p>
<p dir="ltr">Before we get started, here is a list of topics we will be discussing:</p>
<ol>
<li dir="ltr">
<p dir="ltr">What is AMP</p>
</li>
<li dir="ltr">
<p dir="ltr">Setting up AMP on a WordPress site</p>
</li>
<li dir="ltr">
<p dir="ltr">Google Analytics for AMP websites</p>
</li>
<li dir="ltr">Implementing AMP Analytics through Google Tag Manager</li>
</ol>
<p><a ref="magnificPopup" href="https://www.conversioner.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-10-at-15.53.56.png"><img class="aligncenter" alt="amp trends" src="https://www.conversioner.com/wp-content/uploads/2016/11/Screen-Shot-2016-11-10-at-15.53.56-1024x526.png" width="614" height="316" /></a></p>
<h2 dir="ltr">Part #1: What is AMP?</h2>
<p dir="ltr">A lot of content already published about this subject, and I&#8217;m not going to be reinventing the wheel here, but a short overview is in order to make sure everyone is on the same page:</p>
<p dir="ltr">AMP is an open-source project, spearheaded by Google. The initial goal of AMP was to shorten the load time of news sites viewed on mobile devices.</p>
<p><iframe src="https://www.youtube.com/embed/WrpkFROqR0Q" height="452" width="750" allowfullscreen="" frameborder="0"></iframe></p>
<p dir="ltr">However, the project has grown and gained momentum. Consider, for example, that Google recently added AMP to its search results pages, which comes together nicely with the new prioritization of mobile sites, as <a href="http://searchengineland.com/google-clarifies-the-mobile-friendly-algorithm-will-roll-out-over-a-week-be-a-yesno-response-more-217399" target="_blank" rel="nofollow" >announced by Google in April of 2015</a> (note that priority is not yet being given to AMP pages, at least not officially, but this will certainly happen soon).</p>
<p dir="ltr">The reason that Google initiated this project to begin with is due the growing trend of site traffic seeping from the desktop to mobile devices, however most site owners have not yet adapted their site to be properly mobile-friendly (and probably will never do that properly&#8230;).</p>
<p dir="ltr">So yes, &#8220;mobile friendly&#8221;, &#8220;adapted&#8221; and &#8220;responsive&#8221; websites are terms we are already tiring of hearing, but they don&#8217;t actually solve the most significant factor on mobile sites &#8211; i.e., loading times.</p>
<p dir="ltr">Speed critically affects user experience. For example, <a href="https://blog.kissmetrics.com/loading-time/" target="_blank" rel="nofollow" >KISSmetrics&#8217; study</a> found that 40% of a site&#8217;s visitors will leave if the loading time is greater than 3 seconds. If that doesn&#8217;t scare you straight, consider <a href="https://tractusonline.com/how-page-speed-affects-mobile/" target="_blank" rel="nofollow" >another research</a> finding that every second of delay when you website loaded, reduces your conversion rate by 3.5%.</p>
<p dir="ltr">It&#8217;s a lot!</p>
<p dir="ltr">In a funny Google video, they explained this issue in a rather amusing way by showing that the most problematic contributors to lag are the numerous advertising networks and analytics systems installed on the page.</p>
<p dir="ltr">So okay, AdBlocker can solve the problem on the user&#8217;s end &#8211; but then we&#8217;re looking at a serious loss of ROI for the big publishers. This appears to be one of the reasons that Google got involved, to find a solution that will address everyone&#8217;s interest.</p>
<p><iframe src="https://www.youtube.com/embed/lBTCB7yLs8Y" height="452" width="750" allowfullscreen="" frameborder="0"></iframe></p>
<h2 dir="ltr">There are Three Parts in an AMP Website</h2>
<p dir="ltr"><a href="https://www.ampproject.org/learn/about-amp/" target="_blank"  rel="nofollow" >AMP</a> is made up of three central elements:</p>
<ol>
<li dir="ltr">
<p dir="ltr">AMP HTML &#8211; a list of custom tags and a whole lot of restrictions (and a few additions that enable rich content). So, for example, replacing the &lt;img&gt; tag with the &lt;amp-img&gt; tag enables the page to render the images only as the user sees it on his screen &#8211; instead of loading together with all the page&#8217;s elements, which would harm the user experience.</p>
</li>
<li dir="ltr">
<p dir="ltr">AMP JS &#8211; only specific tags can be used in AMP pages, one of the main goals of AMP JS being to turn anything that contains Javascript into an asynchronous element. Loading Javascript in parallel to the page&#8217;s other elements &#8211; instead of upfront, avoids additional load time, which again, would harm the user experience.</p>
</li>
<li dir="ltr">
<p dir="ltr">Google AMP Cache &#8211; Google&#8217;s proxy server saves the pages, and optimizes their display to the user, which of course includes faster loading times.</p>
</li>
</ol>
<p dir="ltr">So, after our quick introduction, let&#8217;s go to the technical part:</p>
<h2 dir="ltr">Part #2: Setting up AMP on a WordPress Site</h2>
<p dir="ltr">First you need to install this AMP Plugin by Automattic with the following link: <a href="https://wordpress.org/plugins/amp/" target="_blank"  rel="nofollow" >https://wordpress.org/plugins/amp</a></p>
<p dir="ltr">[side note]
<p dir="ltr">Since AMP creates a leaner version of your internet site, it is likely that you won&#8217;t like some of the design changes, and you may wish to play a little with the CSS. In order to do so, use a custom action addition to WordPress, as <a href="https://github.com/Automattic/amp-wp/blob/master/readme.md#custom-css" target="_blank"  rel="nofollow" >explained here</a>.</p>
<p dir="ltr">[/end side note]
<p dir="ltr">That&#8217;s pretty much it. From now on, the plugin will create an AMP version for every post or page you have on your site. In order to see it, simply add /amp/ after the post&#8217;s original URL (and if that doesn&#8217;t work, try additing /?amp=1).</p>
<p dir="ltr"><strong>Doesn&#8217;t this cause redundant content?</strong></p>
<p dir="ltr">No, because the plugin adds a canonical tag to the AMP pages that leads to the original content.</p>
<p dir="ltr"><strong>How does Google know to index the AMP pages?</strong></p>
<p dir="ltr">The plugin adds a special tag with <em>rel=&#8221;amphtml&#8221; attribute</em>, which leads to the AMP version of your page. So, when Google&#8217;s crawler indexes the original page, it will see that it also has an AMP version.</p>
<p dir="ltr">This is how this tag works: &lt;link rel=&#8221;amphtml&#8221; href=&#8221;https://www.example.com/url/amp&#8221;&gt;</p>
<h2 dir="ltr">Part #3: Google Analytics in AMP Sites</h2>
<p dir="ltr">Before we get to talk about Tag Manager, let&#8217;s consider why do we need a different <a title="7 Google Analytics Metrics You’re Probably Doing Wrong" href="https://www.conversioner.com/blog/7-google-analytics-metrics-youre-probably-doing-wrong" target="_blank">Google Analytics</a> for our AMP site? Why can&#8217;t we just add them to our regular property?</p>
<p dir="ltr">That&#8217;s an excellent question, and the answer is simple:</p>
<p dir="ltr">The whole idea of AMP is to speed up mobile pages, but because Javascript can often significantly slow down its rendering time (particularly if it is loaded synchronously), the AMP technology doesn&#8217;t allow you to simply embed JS in your page. Instead, it requires you to use a special tag that has been pre-tested and approved by the AMP team.</p>
<p dir="ltr">The AMP team has created tags for the a number of leading analytics systems. You simply add in the desired vendor under the &#8220;type&#8221; attribute (which, as we already said, have been pre-tested and approved):</p>
<div>
<pre>&lt;amp-analytics type="XYZ"&gt; ... &lt;/amp-analytics&gt;</pre>
</div>
<p dir="ltr">Amongst the leading systems already approved by AMP you can find Adobe, Segments, Chartbeat, Yandex and of course Google Analytics.</p>
<p dir="ltr">(Despite all of the above, you can still embed any JS through an iframe, but because we need the Google Analytics code to sit directly within the page, and not be loaded via an external iframe, this isn&#8217;t a solution).</p>
<h3 dir="ltr">Should I split them up into two properties, or measure it all under one property?</h3>
<p dir="ltr">This is a good question, and it depends on the structure of your site. Google recommends opening a separate property.</p>
<p dir="ltr">As these are fundamentally two different kinds of sites, I would recommend including your AMP pages under the regular property, as well as setting up an additional property specifically for AMP, but since AMP uses a different format for tracking the clientId &#8211; you must read <a href="https://www.simoahava.com/analytics/google-analytics-client-id-amp-pages/" target="_blank" rel="nofollow" >Simo Ahava</a>&#8216;s post first.</p>
<p dir="ltr">We need to suppose that the user will also be viewing pages that aren&#8217;t AMP alongside the AMP pages &#8211; so that if you track them across these different pages with separate properties, you may get a cutoff session and lose a lot of information about your visitor.</p>
<h2 dir="ltr">Part #4: Installing AMP Analytics using Google Tag Manager</h2>
<p dir="ltr">Here comes the interesting part.</p>
<p dir="ltr">First of all, we need to open a separate container for our AMP website.</p>
<p dir="ltr">Yes, that&#8217;s right &#8211; you can&#8217;t just use your regular container. As I explained above, AMP was created to speed your site up, so you can&#8217;t use the regular container since it uses a non-adjusted JavaScript.</p>
<p dir="ltr">Besides which, AMP&#8217;s HTML is also customized, so you also can&#8217;t use the Triggers available in the standard container. So, we&#8217;ll open a new container, select AMP, and get the code to embed in our site:</p>
<div dir="rtl"><a ref="magnificPopup" href="https://www.conversioner.com/wp-content/uploads/2016/11/amp-tag-manager-container.png"><img class="aligncenter" alt="amp-tag-manager-container" src="https://www.conversioner.com/wp-content/uploads/2016/11/amp-tag-manager-container-1024x462.png" width="614" height="277" /></a></div>
<div dir="rtl"></div>
<p dir="ltr" style="text-align: center;"><a ref="magnificPopup" href="https://www.conversioner.com/wp-content/uploads/2016/11/amp-taga-manager-code.png"><br />
<img class="aligncenter" alt="amp-taga-manager-code" src="https://www.conversioner.com/wp-content/uploads/2016/11/amp-taga-manager-code-1024x545.png" width="614" height="327" /></a></p>
<p dir="ltr">Before we move on, make sure that you are using a child-theme, as we are going to change the template&#8217;s function.php file. Otherwise, if and when you decide to upgrade the template, this file will be replaced and you will find yourself without any tracking at all&#8230;</p>
<p dir="ltr">Another possibility is to do this using a plugin (<a href="https://wordpress.org/plugins/amp-analytics/" target="_blank"  rel="nofollow" >like this one</a>), but because the combination AMP &lt;&gt; Google Tag Manager is fresh off the press, there is not yet any plugin that enables you to do this without getting your hands a little dirty with code (at the time of this writing).</p>
<p dir="ltr">In any case, I always like to have things hard coded, as this allows me to control what&#8217;s going on, and because I believe that the more plugins you have, the heavier and lower is your website.</p>
<p dir="ltr">After all, AMP was designed to streamline your site&#8217;s rendering, and therefore, we don&#8217;t want to go about slowing it down with a lot of redundant plugins&#8230;</p>
<p dir="ltr">So, after you&#8217;ve created your child template, take the first part of the code and embed it as follows in your function.php file:</p>
<div dir="rtl"><a ref="magnificPopup" href="https://www.conversioner.com/wp-content/uploads/2016/11/amp-tag-manager-part1.png"><img class="aligncenter" alt="amp-tag-manager-part1" src="https://www.conversioner.com/wp-content/uploads/2016/11/amp-tag-manager-part1.png" width="613" height="200" /></a><a ref="magnificPopup" href="https://www.conversioner.com/wp-content/uploads/2016/11/amp-tag-manager-part2.png"><br />
</a></div>
<div dir="ltr"></div>
<p dir="ltr">After that, take the second part of the code and embed it as follows:</p>
<div dir="ltr"><a ref="magnificPopup" href="https://www.conversioner.com/wp-content/uploads/2016/11/amp-tag-manager-part2.png"><img class="aligncenter" alt="amp-tag-manager-part2" src="https://www.conversioner.com/wp-content/uploads/2016/11/amp-tag-manager-part2-1024x321.png" width="614" height="193" /></a></div>
<div dir="rtl"></div>
<p dir="ltr"><em>Please note! If you&#8217;re not highly familiar with code, it is better to give the embedding instructions to an experienced developer. While this is not a complicated setup, the smallest mistake can cause your site to fall.</em></p>
<p dir="ltr"><em>Please note #2: Don&#8217;t forget to change the number in<em> GTM-XXXXXX</em> according to your container id.</em></p>
<p dir="ltr">And&#8230; that&#8217;s it! Tag Manager is now embedded in your site. Now let&#8217;s see how to configure it.</p>
<p dir="ltr">Tag Manager for AMP website includes some really interesting triggers and variables that don&#8217;t come built-in with the regular Tag Manager, but before we discuss them, let&#8217;s create our first tag &#8211; Google Analytics.</p>
<p dir="ltr" style="text-align: center;"><a ref="magnificPopup" href="https://www.conversioner.com/wp-content/uploads/2016/11/Screen-Shot-2016-10-26-at-10.37.23-1.png"><img class="aligncenter" alt="Screen-Shot-2016-10-26-at-10.37.23 (1)" src="https://www.conversioner.com/wp-content/uploads/2016/11/Screen-Shot-2016-10-26-at-10.37.23-1-1024x433.png" width="614" height="260" /></a></p>
<div dir="rtl"></div>
<p dir="ltr">And that&#8217;s it. There aren&#8217;t any special tricks here, and it works here exactly as we&#8217;ve done it up until now with the regular Tag Manager <img src='https://www.conversioner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p dir="ltr">Let&#8217;s move on to the more interesting topics:</p>
<h3>Variables in Tag Manager for AMP</h3>
<p dir="ltr">As you surely already know, the Tag Manager&#8217;s variables are actually &#8220;functions&#8221; that return certain values.</p>
<p dir="ltr">The Page URL variable returns the URL of the page, Data Layer Variable returns values from the data layer, and so on.</p>
<p dir="ltr">As in the regular Tag Manager, we can find built-in variables such as Page URL, Page Hostname, Event, Click Classes, Click ID, Click URL, Form Classes, Form ID, etc. (<a href="https://support.google.com/tagmanager/answer/7182738?hl=en&amp;ref_topic=7182737" target="_blank"  rel="nofollow" >click here for the full list</a>).</p>
<p dir="ltr" style="text-align: center;"><a ref="magnificPopup" href="https://www.conversioner.com/wp-content/uploads/2016/11/built-it-variables-1.png"><img class="aligncenter" alt="built-it-variables-768x467 (1)" src="https://www.conversioner.com/wp-content/uploads/2016/11/built-it-variables-768x467-1.png" width="461" height="280" /></a><a ref="magnificPopup" href="https://www.conversioner.com/wp-content/uploads/2016/11/custom-variables-tag-manager-1.png"><br />
</a></p>
<p dir="ltr">As well, we can also create additional variables manually:</p>
<div dir="ltr"> <a ref="magnificPopup" href="https://www.conversioner.com/wp-content/uploads/2016/11/custom-variables-tag-manager-1.png"><img class="aligncenter" alt="custom-variables-tag-manager (1)" src="https://www.conversioner.com/wp-content/uploads/2016/11/custom-variables-tag-manager-1-686x1024.png" width="412" height="614" /></a></div>
<p dir="ltr">In Google Tag Manager for AMP sites, however, we can find interesting and even downright cool values, such as user&#8217;s time zone, screen width/height, number of pixels the user scrolled, Total Engaged Time (the number of seconds the user was active on the page), page&#8217;s loading time and more (<a href="https://support.google.com/tagmanager/answer/7182413?hl=en&amp;ref_topic=7182737" target="_blank"  rel="nofollow" >link to the full list</a>).</p>
<p dir="ltr">All of these variables are available for use automatically, and all that&#8217;s left to do is to put them into tags, as we will see shortly.</p>
<h3 dir="ltr">Triggers in Tag Manager For AMP</h3>
<p dir="ltr">Google Tag Manager for websites gives us triggers that can track page views, clicks on a certain element, sending a form and custom events that we can send to the data layer (there are of course others, but these are the main ones).</p>
<p dir="ltr">In the AMP container, we will find slightly different triggers, and it is interesting to see that Google also included triggers for scrolling and page visibility:</p>
<p dir="rtl" style="text-align: center;"> <a href="https://lh5.googleusercontent.com/dhO8boHNJyzejA9pKo7Ex3BK4wav4uKoiWlFMme7KM56U73BI399NwXy8hQ5shi_hddurE_iFhrN5IHJBwSD5qtsojWhYQiRx_nSoQz4Rwaf02NYuFMFmM-M8XccwbVj55qNu5jperu0uwvwEQ" target="_blank"  rel="nofollow" ><img class="aligncenter" alt="טריגרים תג מנג'ר AMP" src="https://lh5.googleusercontent.com/dhO8boHNJyzejA9pKo7Ex3BK4wav4uKoiWlFMme7KM56U73BI399NwXy8hQ5shi_hddurE_iFhrN5IHJBwSD5qtsojWhYQiRx_nSoQz4Rwaf02NYuFMFmM-M8XccwbVj55qNu5jperu0uwvwEQ" width="405" height="221" /></a></p>
<h3 dir="ltr">Sending an Event with Tag Manager For AMP</h3>
<p dir="ltr">We saw the Page View trigger in action with the Analytics tag. Let&#8217;s demonstrate tracking the user&#8217;s scrolling actions, and send this event to Google Analytics when the user reaches 25%, 50% and 100% of the page.</p>
<p dir="ltr">All you need to do is to create a new tag called Universal Analytics, enter the number of the property (UA-XXXXXXX-Y format, or by using the Constant variable that we created earlier which contains this number), and enter the desired values under Category/Action/Label/Value.</p>
<p dir="ltr">In my case, I entered a constant value &#8220;Scroll&#8221; under Category, and under Action I put in a variable called {{Scroll Top}}, which returns the number of pixels the user has scrolled down from the top of the page. Under Label, I put in {{Scroll Height}} that will return the height of the page in pixels (both are built-in variables):</p>
<div dir="rtl"></div>
<p dir="rtl" style="text-align: center;"><a href="https://lh5.googleusercontent.com/6NGYz70JuyACcbUZgtPnixshhA_qlUgOJjOKWXQMM25rOqG6S_LW_-e5lo6R3Xko7p5RHqPyVb5Yz_cCy5vQy8DmtzXstvDhiblWAlyyfxBnJUuWn_L8XyRVSWbGaA0olms3eYQ3tOnZrmX5dQ" target="_blank"  rel="nofollow" ><img class="aligncenter" alt="scroll tag tag manager" src="https://lh5.googleusercontent.com/6NGYz70JuyACcbUZgtPnixshhA_qlUgOJjOKWXQMM25rOqG6S_LW_-e5lo6R3Xko7p5RHqPyVb5Yz_cCy5vQy8DmtzXstvDhiblWAlyyfxBnJUuWn_L8XyRVSWbGaA0olms3eYQ3tOnZrmX5dQ" width="321" height="412" /></a></p>
<p dir="ltr">After this, I&#8217;ll create the trigger that is supposed to send this event, and under Vertical percentages I will enter the percentage points at which I wish to send the event. It is possible to enter a list of more than one area, by using commas:</p>
<p dir="rtl" style="text-align: center;"><a href="https://lh6.googleusercontent.com/qjdysGt4TiU2yAfeqZhkeQXzY98VRqIy_5OAZlxFsaiUSrgJN-9q76pAnj45P4nZymIBJmelrTle-CUz_unIW3hLwdrm3s8fFDsMDnFHKKHJsoo7nNTPLocN5PkAITW3E5U4S8rgN-_PW0fLhA" target="_blank"  rel="nofollow" ><img class="aligncenter" alt="scroll-trigger-tag-manager" src="https://lh6.googleusercontent.com/qjdysGt4TiU2yAfeqZhkeQXzY98VRqIy_5OAZlxFsaiUSrgJN-9q76pAnj45P4nZymIBJmelrTle-CUz_unIW3hLwdrm3s8fFDsMDnFHKKHJsoo7nNTPLocN5PkAITW3E5U4S8rgN-_PW0fLhA" width="367" height="203" /></a></p>
<div dir="ltr"></div>
<p dir="ltr">Usually, I debug my events using Google Analytics Debugger, but it (as yet) does not support events that are sent by AMP pages.</p>
<p dir="ltr">As a bit of a shortcut, I will simply use the Network section in Chrome, and there I will be able to see all of the requests that the browser sends to the Google Analytics servers.</p>
<p dir="ltr">Of course, it is also possible to see the events sent to Analytics via the real-time report, but I just think it&#8217;s redundant to keep switching between the windows&#8230;</p>
<p dir="ltr" style="text-align: center;"><a ref="magnificPopup" href="https://www.conversioner.com/wp-content/uploads/2016/11/scroll-event-debugging.png"><img class="aligncenter  wp-image-4885" alt="scroll-event-debugging" src="https://www.conversioner.com/wp-content/uploads/2016/11/scroll-event-debugging-1024x838.png" width="614" height="503" /></a></p>
<h3 dir="ltr">Tracking Clicks in AMP Pages Using Google Tag Manager</h3>
<p dir="ltr">Tracking scrolling actions is nice, but let&#8217;s see how I track users that have left my AMP pages after clicking on Leave a Comment. Supposedly, they have left the site, but I want to know whether they have actually left my site, or just gone to my regular mobile site, which is being measured under a different property than that of the AMP property, which starts another session.</p>
<p dir="ltr"><a ref="magnificPopup" href="https://www.conversioner.com/wp-content/uploads/2016/11/Screen-Shot-2016-10-26-at-20.28.12-1.png"><img class="aligncenter size-full wp-image-4886" alt="Screen-Shot-2016-10-26-at-20.28.12 (1)" src="https://www.conversioner.com/wp-content/uploads/2016/11/Screen-Shot-2016-10-26-at-20.28.12-1.png" width="624" height="139" /></a></p>
<p dir="ltr">This is also exceedingly simple. All I need to do is to create a new Event tag for Universal Analytics, but this time I will use a different built-in variable, called {{Total Engaged Time}}. This will give me the number of seconds that the user was active on the page, giving me an indication of how much time it took the user to read the article and then leave a comment.</p>
<p dir="ltr">Afterwards, I will be able to compare this to other actions made by other visitors, and extract my insights about the ideal amount of time the user should be on my page in order to leave a comment.</p>
<p dir="rtl" style="text-align: center;"><a href="https://lh5.googleusercontent.com/6KAy2DyqYWspJHdXXIc_PMGjqV_wD2zDXzE0WLggw5OsWfuCTZ8SlpyiaLUSHpzW0kguf5qUWYVs7n1u1dQAYY775ecWzV5HNV6otGqaPeN-c8XOtJDr_MNoRJWgYkyKWIWekw5zz6R5-Csn_w" target="_blank"  rel="nofollow" ><img class="aligncenter" alt="leave a comment class tracking" src="https://lh5.googleusercontent.com/6KAy2DyqYWspJHdXXIc_PMGjqV_wD2zDXzE0WLggw5OsWfuCTZ8SlpyiaLUSHpzW0kguf5qUWYVs7n1u1dQAYY775ecWzV5HNV6otGqaPeN-c8XOtJDr_MNoRJWgYkyKWIWekw5zz6R5-Csn_w" width="283" height="374" /></a></p>
<div dir="rtl"></div>
<p dir="ltr">The trigger for this tag should be Click event, then CSS Selector and then I will add &#8220;.amp-wp-comments-link a&#8221;.</p>
<p dir="rtl" style="text-align: center;"><a href="https://lh6.googleusercontent.com/J7DyLs95CGV55YgYGEUWCqvKqBX9mx8bPPp6KjjFLLbWEqZKuOnQHcqUyIc6qEqTcbcjtERT-A0QDZ7MhVvNvcjjp-RPPhsnHzsWiSs_QZ0HMEblv2QNYMqvcaqUCbDwBpSCXa6XAHbekKpkqQ" target="_blank"  rel="nofollow" ><img class="aligncenter" alt="leave a comment" src="https://lh6.googleusercontent.com/J7DyLs95CGV55YgYGEUWCqvKqBX9mx8bPPp6KjjFLLbWEqZKuOnQHcqUyIc6qEqTcbcjtERT-A0QDZ7MhVvNvcjjp-RPPhsnHzsWiSs_QZ0HMEblv2QNYMqvcaqUCbDwBpSCXa6XAHbekKpkqQ" width="440" height="198" /></a></p>
<p dir="ltr">Please note that in this case, we are talking about an a element which is inside a div element (which holds the class), and therefore I entered both elements, dividing between them using a comma. You can never know in advance which element the tag manager will decide to identify as the clicked element, and so it is always worthwhile to put in both the main element as well as any sub elements &#8211; just to be on the safe side.</p>
<p dir="ltr"><strong>Important:</strong> As the AMP completely changes the structure of your site, note that the selectors that we will want to use are completely different from the selectors that you are familiar with from your regular site.</p>
<p dir="ltr">Let&#8217;s debug this &#8211; we&#8217;ll click on the button and see whether the event was sent:</p>
<p dir="rtl" style="text-align: center;"><a href="https://lh6.googleusercontent.com/Ut-94bhgd3ifhtiw6K1pUb39tX2-w4OxoInICUW2AfV1AuywWoscQiKrLiXI4W5A8_RKqUhIFQL8QEjwGeL4JMH2aRKxtDxiaJfTRCqp_qFWLZws7rb_D1EIvhRCGpGqyAfybUza2ySW6coxtA" target="_blank"  rel="nofollow" ><img class="aligncenter" alt="דיבאגינג" src="https://lh6.googleusercontent.com/Ut-94bhgd3ifhtiw6K1pUb39tX2-w4OxoInICUW2AfV1AuywWoscQiKrLiXI4W5A8_RKqUhIFQL8QEjwGeL4JMH2aRKxtDxiaJfTRCqp_qFWLZws7rb_D1EIvhRCGpGqyAfybUza2ySW6coxtA" width="531" height="126" /></a></p>
<p dir="ltr">Indeed it has, it has been sent, but with a small bug. You may have noticed what appears under Event Label is the main domain, without the path, despite I used {{Page URL}} variable. I am working on this with Google to figure out why this happens, and will update this post once I have an answer.</p>
<div dir="rtl"></div>
<h2 dir="ltr">Conclusion</h2>
<p dir="ltr">Contrary to what you (might have) thought at the beginning, setting up Google Analytics via Tag Manager in AMP sites (and using Tag Manager in AMP sites generally) is much more simple than Tag Manager for regular web sites.</p>
<p dir="ltr">In light of the simplicity with which we can enable WordPress sites to support AMP, and in light of the fact that Google is pushing this so hard &#8211; it is very likely to become a standard in the near future. I think that every website manager and owner should make this change, and the quicker &#8211; the better.</p>
<p dir="ltr">And let&#8217;s not forget the improvement to user experience. This was the main reason that Google got into AMP, so no matter how you look at it, I believe it&#8217;s very worth your while to start planning this changeover today, and of course, to set up your tracking properly.</p>
</div></div></div><p>The post <a href="https://www.conversioner.com/blog/google-analytics-amp-website-google-tag-manager">Implementing Google Analytics in AMP Websites Using Google Tag Manager</a> appeared first on <a href="https://www.conversioner.com">Conversioner</a>.</p>]]></content:encoded>
			<wfw:commentRss>https://www.conversioner.com/blog/google-analytics-amp-website-google-tag-manager/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
