ampproject / ampproject/amphtml
amp-analytics doesn't find an element
- Dominant language
- JavaScript
- Stars
- 14.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
## What's the issue?
I am using `amp-analytics` to track my ads, but when using `amp-analytic` with `amp-auto-ads` it doesn’t track for the elements created after the `amp-analytics` has been loaded.
I believe this is happening with all amp extensions that dynamically loads elements on the page and not only `amp-auto-ads`.
Error message
> Element "XXX" not found: null
## How do we reproduce the issue?
I created 2 environments trying to simulate a delay on the extension so I can reproduce the error that occurs depending on user’s network:
1 – I delayed in 1 second the `amp-analytics` request: https://delay-amp-analytics.denakop.com/amp.html
2 – I delayed in 1 second the `amp-auto-ad` request: https://delay-amp-auto-ads.denakop.com/amp.html
When delaying the `amp-analytics` the error will not occur because the selector exists.
When delaying `amp-auto-ad` the `amp-analytics` will throw an error because when it is loaded the `` elements is not created yet
## What browsers are affected?
I managed to reproduce the error on all major browsers and devices.
## Which AMP version is affected?
I believe this issue is happening in all AMP versions
Contributor guide
Assessment
This issue has not been assessed yet.