I would like to trigger an analytics event after the user has spent 10 seconds on the page. This is the code I'm using
> "pageTimer": {
> "on": "timer",
> "timerSpec": {
> "interval": 10,
> "maxTimerLength": 9.99
> },
> "request": "event",
> "vars": {
> "eventCategory": "Profitable Engagement",
> "eventAction": "more than 10s"
> }
> }
The problem is, that with this code 2 events are fired: one on page load, and one after 10 seconds.
Is there a way to prevent this behavior, and fire only 1 event?
Live example: https://www.guidallascelta.it/tecnologia/computer/i-migliori-software-per-il-recupero-dati-da-hard-disk-e-non-solo/amp/
Also on the AMP by example site you can see the same behavior: https://ampbyexample.com/components/amp-analytics/#timer
As soon as you load the page, the timer count is set to 1 instead of 0. Then it increases every 10 seconds up to 60.
Thanks!
Use immediate
false
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"
}
}