当amp-state从src sttribute获得响应时调用amp-analytics

时间:2018-11-01 06:13:30

标签: amp-html

实际上,当从src属性通过amp-state获得响应时,我想调用我的amp分析。查找以下代码。在这种情况下,我将使用变量替换“ vstrType”插入从amp-state到amp-analytics的响应:“ $ {ampState(vstrT.count)}”

<amp-state id="vstrT" src="https://ampbyexample.com/favorite-with-count"><script type="application/json">
    {
      "foo": "bar"
    }
  </script>
</amp-state>
<amp-analytics type="segment">
    <script type="application/json">
	{
		"vars": {
			"vstrType": "${ampState(vstrT.count)}",
			"anonymousId": "CLIENT_ID(segment_amp_id)",
			"writeKey": "***********",
			"name": "page title"
		},
		"requests": {
			"host": "https://api.segment.io/v1/pixel",
			"base": 
			"extraUrlParams": "properties.VType=${vstrType},  
			"page": "${host}/page${base}&name=${name}&${extraUrlParams}&pageLoadTime=${pageLoadTime}"
		},
		"triggers": {
			"page": {
			"on": "visible",
			"request": "page"
			}
		}
	}
    </script>
</amp-analytics>

0 个答案:

没有答案