计时器在 amp-analytics 中触发两次
Timer triggered twice in amp-analytics
我想在用户在页面上停留 10 秒后触发分析事件。这是我使用的代码
> "pageTimer": {
> "on": "timer",
> "timerSpec": {
> "interval": 10,
> "maxTimerLength": 9.99
> },
> "request": "event",
> "vars": {
> "eventCategory": "Profitable Engagement",
> "eventAction": "more than 10s"
> }
> }
问题是,使用此代码会触发 2 个事件:一个在页面加载时,一个在 10 秒后。
有没有办法防止这种行为,并且只触发 1 个事件?
在 AMP by example 站点上,您也可以看到相同的行为:https://ampbyexample.com/components/amp-analytics/#timer
一旦您加载页面,计时器计数就会设置为 1 而不是 0。然后每 10 秒增加一次,直到 60。
谢谢!
使用immediate
错误
The timer will trigger immediately (by default, can be unset) and then at a specified interval thereafter, immediate trigger timer immediately or not. Boolean, defaults to true
"pageTimer": {
"on": "timer",
"timerSpec": {
"interval": 10,
"maxTimerLength": 9.99,
"immediate":false
},
"request": "event",
"vars": {
"eventCategory": "Profitable Engagement",
"eventAction": "more than 10s"
}
}
我想在用户在页面上停留 10 秒后触发分析事件。这是我使用的代码
> "pageTimer": {
> "on": "timer",
> "timerSpec": {
> "interval": 10,
> "maxTimerLength": 9.99
> },
> "request": "event",
> "vars": {
> "eventCategory": "Profitable Engagement",
> "eventAction": "more than 10s"
> }
> }
问题是,使用此代码会触发 2 个事件:一个在页面加载时,一个在 10 秒后。
有没有办法防止这种行为,并且只触发 1 个事件?
在 AMP by example 站点上,您也可以看到相同的行为:https://ampbyexample.com/components/amp-analytics/#timer
一旦您加载页面,计时器计数就会设置为 1 而不是 0。然后每 10 秒增加一次,直到 60。
谢谢!
使用immediate
错误
The timer will trigger immediately (by default, can be unset) and then at a specified interval thereafter, immediate trigger timer immediately or not. Boolean, defaults to true
"pageTimer": {
"on": "timer",
"timerSpec": {
"interval": 10,
"maxTimerLength": 9.99,
"immediate":false
},
"request": "event",
"vars": {
"eventCategory": "Profitable Engagement",
"eventAction": "more than 10s"
}
}