Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow on: visible to listen to amp-list items. #27835

Closed
erakor opened this issue Apr 17, 2020 · 8 comments
Closed

Allow on: visible to listen to amp-list items. #27835

erakor opened this issue Apr 17, 2020 · 8 comments

Comments

@erakor
Copy link

erakor commented Apr 17, 2020

What

When you use amp-list (way below the fold), it should be possible to add a visibility tracker on those amp-list's items when they start showing up. It's currently not possible as the id the listeners are attached to are not present yet.

Additional context

The visibilitySpec options don't seem to help.

@caroqliu
Copy link
Contributor

Thanks for filing this feature request! Can you provide more information on how you anticipate using this? Since AMP actions and events can be used to create dynamic experiences, and something like a on: visible event would be passively triggered rather than intentionally done with user interaction, would this feature be able to fulfill your use case with a low-trust event?

@erakor
Copy link
Author

erakor commented May 7, 2020

Hi @caroqliu!

We load recommended articles via amp-list at the end of our articles.
We would like to track impressions of the list items.

However, expectedly, browser throws an error when trying to track visibility for something that's not there yet:

"visibilityReco_1": {
    "on": "visible",
    "request": "event",
    "selector": "#list_item_1",
    "visibilitySpec": {...}
}

Throws

Uncaught (in promise) Error: Element "#list_item_1" not found: null​​​

Is this enough info?

@erakor
Copy link
Author

erakor commented May 7, 2020

I found another thread issue (from 2017) for a similar request that ended up with the addition of the ini-load trigger.
I don't think the solution was what was requested though.

@erakor
Copy link
Author

erakor commented May 7, 2020

Actually, I keep mentioning on: visible as the trigger we're looking forward to having but none of the triggers work for amp-list items as far as we're concerned.
We'd love to see more opportunities to use amp-analytics within amp-list.

@erakor
Copy link
Author

erakor commented May 7, 2020

Other closed issue (#3857) supposedly fixed.

@caroqliu
Copy link
Contributor

caroqliu commented May 7, 2020

cc @ampproject/wg-analytics

@zhouyx
Copy link
Contributor

zhouyx commented May 7, 2020

Thanks for reporting this. Yes this is a known issue. <amp-analytics> observe elements during initialization once. Because of that dynamic element that's loaded after <amp-analytics> initialization won't be observed.

Another restriction that you may encounter is: AMP doesn't support tracking the visibility of non AMP elements. We are working to remove this restriction.

#21727 is related. And you may be able to fix it by placing the <amp-analytics> within the <amp-list>.

@erakor
Copy link
Author

erakor commented May 20, 2020

@zhouyx @caroqliu
Placing <amp-analytics> within the <amp-list> did the trick.
Thank you both!

@erakor erakor closed this as completed May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants