ampproject / ampproject/amphtml
[amp-auto-ads] Multiple amp-auto-ads on the same page - adConstraints are not kept
- Dominant language
- JavaScript
- Stars
- 14.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to understand if multiple amp-auto-ads from different networks would work correctly if implemented simultaneously on the same page.
Currently I am facing the issue that adConstraints are not really kept. I think that each auto-ads instance keeps distance from ads that were previously present on the page, but they ignore ads created by each other.
Here is example link, where both AdSense and FirstImpression.io are implemented, both networks have constraint of at least one viewport height distance between ads, but ads still appear next to each other.
https://www.favecrafts.com/Knit-Baby-Blankets/Easy-Free-Knitting-Patterns-and-Help/amp#fi_reveal=113853 (preferably to look in mobile emulator)
Here how it looks like were the problem exists, ads are too close to each other:

Is this a config issue, or multiple amp-auto-ads are expeted to work like that?
**_Additional info:_**
AdConstriants from AdSense:
```
"adConstraints": {
"initialMinSpacing":"1vp",
"subsequentMinSpacing": [
{"adCount":3,"spacing":"2vp"},
{"adCount":6,"spacing":"3vp"}
],
"maxAdCount":8
}
```
AdConstraints from FirstImpression.io:
```
"adConstraints": {
"initialMinSpacing":"609px",
"subsequentMinSpacing": [{"adCount":10,"spacing":"200px"}],
"maxAdCount":100
}
```
@tlong2
Contributor guide
Research direction
Start with the amp-auto-ads implementation and reproduce the behavior using the linked page in a mobile emulator, with AdSense and FirstImpression.io enabled together. Compare the configured adConstraints with the resulting ad spacing; done means determining whether constraints are shared across instances and documenting or correcting the observed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100