Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
320 lines (316 sloc) 12.5 KB
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<title>AMP Analytics</title>
<link rel="canonical" href="analytics.amp.html" >
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-custom>
.box {
background: #ccc;
border: 1px solid #aaa;
padding: 10px;
margin: 10px;
}
#container {
position: absolute;
top: 10000px;
height: 10px;
}
</style>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-anim" src="https://cdn.ampproject.org/v0/amp-anim-0.1.js"></script>
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
<script async custom-element="amp-video" src="https://cdn.ampproject.org/v0/amp-video-0.1.js"></script>
</head>
<body>
<p>Scroll down to see content</p>
<div id="container">
Container for analytics tags. Positioned far away from top to make sure that doesn't matter.
<amp-analytics>
<script type="application/json">
{
"requests": {
"endpoint": "/analytics/no-referrer"
},
"triggers": {
"pageview": {
"on": "visible",
"request": "endpoint"
}
},
"transport": {
"referrerPolicy": "no-referrer"
}
}
</script>
</amp-analytics>
<amp-analytics id="analytics1">
<script type="application/json">
{
"transport": {"beacon": true, "xhrpost": false},
"requests": {
"endpoint": "/analytics",
"base": "${endpoint}/${type}?path=${canonicalPath}",
"event": "${base}&scrollY=${scrollTop}&scrollX=${scrollLeft}&height=${availableScreenHeight}&width=${availableScreenWidth}&scrollBoundV=${verticalScrollBoundary}&scrollBoundH=${horizontalScrollBoundary}",
"visibility": "${base}&a=${maxContinuousVisibleTime}&b=${totalVisibleTime}&c=${firstSeenTime}&d=${lastSeenTime}&e=${firstVisibleTime}&f=${lastVisibleTime}&g=${minVisiblePercentage}&h=${maxVisiblePercentage}&i=${elementX}&j=${elementY}&k=${elementWidth}&l=${elementHeight}&m=${totalTime}&n=${loadTimeVisibility}&o=${backgroundedAtStart}&p=${backgrounded}&subTitle=${subTitle}",
"timer": "${base}&backgroundState=${backgroundState}&timerStart=${timerStart}&duration=${timerDuration}",
"video": "${base}&type=${type}&currentTime=${currentTime}&f=${fullscreen}&a=${autoplay}"
},
"vars": {
"title": "Example Request"
},
"extraUrlParams": {
"param1": "${random}",
"platform": "AMP"
},
"extraUrlParamsReplaceMap": {
"param": "p"
},
"triggers": {
"pageview": {
"on": "visible",
"request": "base",
"vars": {
"type": "pageLoad"
},
"extraUrlParams": {
"param1": "Another value"
}
},
"visibility": {
"on": "visible",
"request": "visibility",
"selector": "#anim-id",
"visibilitySpec": {
"visiblePercentageMin": 20,
"visiblePercentageMax": 80,
"totalTimeMin": 5000,
"continuousTimeMin": 2000,
"waitFor": "ini-load"
},
"vars": {
"type": "visible"
}
},
"hidden": {
"on": "hidden",
"request": "visibility",
"visibilitySpec": {
"selector": "#anim-id",
"visiblePercentageMin": 20,
"visiblePercentageMax": 1000,
"continuousTimeMax": 5000
},
"vars": {
"type": "hidden"
}
},
"scrollPings": {
"on": "scroll",
"request": "event",
"scrollSpec": {
"verticalBoundaries" : [1, 50, 90],
"horizontalBoundaries": [100]
},
"vars": {
"type": "scroll"
}
},
"clickPings": {
"on": "click",
"selector": "${img}",
"request": ["endpoint", "base"],
"vars": {
"type": "click",
"img": "#anim-id, #container"
}
},
"timer": {
"on": "timer",
"timerSpec": {
"interval": 5,
"maxTimerLength": 20
},
"request": "timer",
"vars": {
"type": "timer"
}
},
"videoPlays": {
"on": "video-play",
"selector": "#myVideo",
"videoSpec": {
"exclude-autoplay": true
},
"request": "video",
"vars": {
"type": "video-play"
}
},
"videoPauses": {
"on": "video-pause",
"selector": "#myVideo",
"videoSpec": {
"exclude-autoplay": false
},
"request": "video",
"vars": {
"type": "video-pause"
}
},
"videoSession": {
"on": "video-session",
"selector": "#myVideo",
"videoSpec": {
"end-session-when-invisible": true,
"exclude-autoplay": false
},
"request": "video",
"vars": {
"type": "video-session"
}
},
"videoSecondsPlayed": {
"on": "video-seconds-played",
"selector": "#myVideo",
"videoSpec": {
"end-session-when-invisible": false,
"exclude-autoplay": false,
"interval": 3
},
"request": "video",
"vars": {
"type": "video-seconds-played"
}
},
"videoEnded": {
"on": "video-ended",
"selector": "#myVideo",
"videoSpec": {
"end-session-when-invisible": true,
"exclude-autoplay": false
},
"request": "video",
"vars": {
"type": "video-ended"
}
}
}
}
</script>
</amp-analytics>
<amp-analytics id="analytics3" config="./analytics.config.json"></amp-analytics>
<div class="logo"></div>
<h1 id="top">AMP Analytics</h1>
<span id="test1" class="box" data-vars-title="Example request with element level overrides">
Click here to generate an event
</span>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam pellentesque augue quis elementum tempus. Pellentesque sit amet neque bibendum, sagittis purus vitae, pellentesque magna. Vestibulum non viverra metus, eget feugiat lacus. Nulla in maximus orci. Maecenas id turpis vel ipsum vestibulum bibendum ut sit amet magna. Nullam hendrerit ex at est eleifend, nec dignissim nibh rutrum. Aliquam quis tellus et nibh faucibus laoreet in eget turpis. Nam quam nisl, porttitor vel ex eget, dapibus placerat dui. Mauris commodo pellentesque leo, eu tempus quam. In hac habitasse platea dictumst. Suspendisse non ante finibus, luctus augue non, luctus orci. Vestibulum ornare lacinia aliquam. In sollicitudin vehicula vulputate. Sed mi elit, commodo nec sapien nec, pretium bibendum leo. Donec id justo tortor. Ut in mauris dapibus, laoreet metus vitae, dictum nisi.
</p>
<p>
Integer dapibus egestas arcu. Nunc vitae velit congue, placerat augue quis, suscipit nisi. Donec suscipit imperdiet turpis pharetra feugiat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus aliquam eleifend dolor, at lacinia orci semper vel. Nunc semper sem vel tincidunt posuere. Nunc lobortis velit vitae condimentum mollis. Morbi eu ullamcorper mauris. Pellentesque ac eros maximus, pulvinar sapien vitae, semper nisi. Curabitur imperdiet non mauris vitae sollicitudin.
</p>
<p>
Nam posuere velit euismod risus pulvinar, in sollicitudin sapien consectetur. Vestibulum nec ex odio. Quisque at elit nec nunc ultricies lacinia nec non lorem. Maecenas porttitor consequat mauris, vitae porttitor ligula pellentesque ut. Pellentesque rhoncus diam vel lacus lobortis imperdiet. Sed maximus dictum hendrerit. Vivamus ornare, purus in laoreet sagittis, est ante pretium mauris, vel vulputate arcu erat eget mauris. Suspendisse eu lorem metus. Aliquam tempus aliquet urna, vitae mollis lacus pretium vitae. Etiam semper gravida commodo. Maecenas at pulvinar quam. Nullam dolor ipsum, ornare a sollicitudin et, sodales porttitor neque.
</p>
<p>
Integer in felis at lacus mattis facilisis. Curabitur tincidunt, felis porttitor mollis finibus, tortor elit elementum dolor, vel vulputate lorem dui id ante. Vivamus in velit at lectus blandit gravida vitae quis arcu. Nam et magna magna. Fusce condimentum diam lacus, ac ullamcorper purus malesuada eu. Mauris ullamcorper elit et venenatis faucibus. Nullam lobortis molestie purus quis pellentesque. Sed at libero id nisi rhoncus tincidunt. Praesent vestibulum vehicula tristique. Etiam rutrum, nunc id porta interdum, nulla nisi molestie leo, at fermentum justo dolor at lorem. Duis in egestas sapien.
</p>
<amp-video
id="myVideo"
src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerJoyrides.mp4"
width="358"
height="204"
layout="responsive"
controls
autoplay
>
<div placeholder>
This is a placeholder
</div>
<div fallback>
This is a fallback
</div>
</amp-video>
<button on="tap:myVideo.pause">Pause</button>
<p>
Donec pharetra molestie sollicitudin. Duis mattis eleifend rutrum. Quisque luctus tincidunt lacus, vitae lobortis nisi malesuada ac. Aliquam mattis leo vel elit rutrum, nec consequat massa vestibulum. Maecenas bibendum metus nec ante feugiat, eu faucibus orci mattis. Cras tristique sem non elit congue malesuada. Proin ornare, lacus et porttitor consequat, sapien urna rutrum diam, ac pellentesque ligula est eget nisi. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec ultrices sollicitudin eros a placerat. Proin eget pulvinar est. Donec posuere ultrices odio at ultrices. Suspendisse potenti. Phasellus id orci id purus porttitor consectetur a at erat. Nullam volutpat ultricies nisl id maximus. Morbi porta ex ante, et egestas odio ultricies consequat.
</p>
<p>
<ul>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
<li>Aliquam in ex porta, imperdiet elit sit amet, condimentum diam.</li>
<li>Etiam fermentum nisi at porta pulvinar.</li>
</ul>
</p>
<p>
<ul>
<li>Proin mattis neque vel elit posuere molestie.</li>
<li>Integer tincidunt sem sed nunc auctor elementum.</li>
<li>Integer a felis in ipsum aliquet auctor sit amet a neque.</li>
</ul>
</p>
<p>
<ul>
<li>Sed suscipit dolor molestie, rhoncus quam ac, lacinia ex.</li>
<li>Curabitur et tellus vel justo ultrices aliquet sed id turpis.</li>
<li>Nam finibus risus at justo elementum bibendum.</li>
<li>In non lacus non urna congue feugiat at vel diam.</li>
</ul>
</p>
<p>
<ul>
<li>Integer hendrerit augue interdum dui venenatis, sit amet tristique mauris cursus.</li>
<li>Etiam quis eros viverra, tincidunt justo in, facilisis nunc.</li>
<li>Aliquam at lacus faucibus, congue lorem interdum, semper mauris.</li>
<li>Ut vulputate erat vel feugiat pharetra.</li>
<li>Morbi id augue id orci sagittis tempus.</li>
<li>Vestibulum varius libero ac dignissim sodales.</li>
</ul>
</p>
<p>
<ul>
<li>Aenean ac sem eget libero varius viverra sit amet vitae nunc.</li>
</ul>
</p>
<amp-anim src="https://www.google.com/logos/doodles/2016/2016-doodle-fruit-games-day-14-5645577527230464-hp.gif" id="anim-id" width="665" height="220" layout="responsive">
<amp-img placeholder src="https://www.google.com/logos/doodles/2016/2016-doodle-fruit-games-day-14-5645577527230464.2-scta.png" width="665" height="220" layout="responsive"></amp-img>
<amp-analytics id="nestedAnalytics">
<script type="application/json">
{
"transport": {"beacon": true, "xhrpost": false},
"requests": {
"visibility": "/analytics/${type}?RANDOM"
},
"triggers": {
"visibilityScope": {
"on": "visible",
"request": "visibility",
"visibilitySpec": {
"selector": "amp-img",
"selectionMethod": "scope",
"visiblePercentageMin": 10
},
"vars": { "type": "visible-scope" }
},
"visibilityClosest": {
"on": "visible",
"request": "visibility",
"visibilitySpec": {
"selector": "amp-anim",
"selectionMethod": "closest",
"visiblePercentageMin": 20
},
"vars": { "type": "visible-closest" }
}
}
}
</script>
</amp-analytics>
</amp-anim>
</div>
</body>
</html>