title: AMP analytics events for scroll
body: <p>I am trying to add analytics to my AMP page.while tra</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html amp lang="en"&gt;
  
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;Hello, AMP Analytics&lt;/title&gt;
    &lt;link rel="canonical" href="http://example.ampproject.org/article-metadata.html" /&gt;
    &lt;meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"&gt;
    &lt;script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"&gt;&lt;/script&gt;
    &lt;style&gt;
      body {
        opacity: 0
      }
    &lt;/style&gt;&lt;noscript&gt;&lt;style&gt;body {opacity: 1}&lt;/style&gt;&lt;/noscript&gt;
    &lt;script async src="https://cdn.ampproject.org/v0.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;amp-analytics type="googleanalytics"&gt;
      &lt;script type="application/json"&gt;
        {
          "vars": {
            "account": "UA-xxxxxxxx-x"
          },
          "triggers": {
            "trackPageview": {
              "on": "visible",
              "request": "pageview"
            },
            "scrollPings": {
              "on": "scroll",
              "scrollSpec": {
                "verticalBoundaries": [10, 20, 30, 40, 50, 60, 70, 80, 90]
              },
              "request": "event",
              "vars": {
                "eventId": "scroll"
              }
            },
            "trackEvent": {
              "selector": "#event-test",
              "on": "click",
              "request": "event",
              "vars": {
                "eventCategory": "${canonicalUrl}",
                "eventAction": "click"
              }
            }
  
          }
        }
      &lt;/script&gt;
    &lt;/amp-analytics&gt;
  
    &lt;h1 id="header"&gt;AMP Page&lt;/h1&gt;
  
    &lt;span id="event-test" class="box"&gt;
      Click here to generate an event
    &lt;/span&gt;
    &lt;h2&gt;
  
      Page semi-protected Blog From Wikipedia, the free encyclopedia "Blogger" redirects here. For the Google service with same name, see Blogger (service). For other uses, see Blog (disambiguation). Not to be confused with .blog. Journalism Simons Perskaart
      DOM.jpg News Writing style Ethics Objectivity News values Attribution Defamation Editorial independence Journalism school Index of journalism articles Areas Arts Business Data Entertainment Environment Fashion Medicine Politics Science Sports Technology
      Trade Traffic Weather World Genres Advocacy Analytic Blogging Broadcast Citizen Civic Collaborative Comics-based Community Data Database Gonzo Immersion Investigative Literary Muckraking Narrative "New Journalism" Non-profit Online Opinion Peace Photojournalism
      Scientific Sensor Underground Visual Watchdog Social impact Fake news Fourth Estate Fifth Estate Freedom of the press Infotainment Media bias Public relations Press service Propaganda model Yellow journalism News media Newspapers Magazines TV and
      radio Internet News agencies Alternative media Roles Journalists (reporters) Columnist Blogger Editor Copy editor Meteorologist News presenter Photographer Pundit / commentator Newspaper nicu buculei 01.svg Journalism portal Category: Journalism v
      t e A blog (a truncation of the expression "weblog")[1] is a discussion or informational website published on the World Wide Web consisting of discrete, often informal diary-style text entries ("posts"). Posts are typically displayed in reverse chronological
      order, so that the most recent post appears first, at the top of the web page. Until 2009, blogs were usually the work of a single individual,[citation needed] occasionally of a small group, and often covered a single subject or topic. In the 2010s,
      "multi-author blogs" (MABs) have developed, with posts written by large numbers of authors and sometimes professionally edited. MABs from newspapers, other media outlets, universities, think tanks, advocacy groups, and similar institutions account
      for an increasing quantity of blog traffic. The rise of Twitter and other "microblogging" systems helps integrate MABs and single-author blogs into the news media. Blog can also be used as a verb, meaning to maintain or add content to a blog. This
      page was last edited on 18 May 2017, at 21:34. Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered
      trademark of the Wikimedia Foundation, Inc., a non-profit organization. Privacy policyAbout WikipediaDisclaimersContact WikipediaDevelopersCookie statementMobile viewWikimedia Foundation Powered by MediaWiki
    &lt;/h2&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>ckPageview and trackEvent generate events. scrollPings does not.
  Has anybody tries this out?
  ** The reference code for scrollPing is from AMP by Example page.
  Thanks in advance </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt; amp - analytics type = "googleanalytics" &gt;
    &lt;script type = "application/json" &gt; {
      "vars": {
        "account": "UA-XXXXXXXX-X"
      },
      "triggers": {
        "trackPageview": {
          "on": "visible",
          "request": "pageview"
        },
        "scrollPings": {
          "on": "scroll",
          "scrollSpec": {
            "verticalBoundaries": [10, 20, 30, 40, 50, 60, 70, 80, 90]
          },
          "request": "event",
          "vars": {
            "eventId": "scroll"
          }
        },
        "trackEvent": {
          "selector": "#event-test",
          "on": "click",
          "request": "event",
          "vars": {
            "eventCategory": "${canonicalUrl}",
            "eventAction": "click"
          }
        }
  
      }
    } 
  &lt;/script&gt; 
  &lt;/amp-analytics&gt;</code></pre>
  </div>
  </div>
  </p>