when would amp-pixel get fired is not documented well
or, maybe totally wrong and unexpected.
With the current implementation, amp-pixel fires when amp-pixel gets laid out. Meaning if pub has put it at the bottom at the page, it will not fire until user scroll down till it get close to the viewport.
This would lead inaccurate page view stats.
Solutions:
- Clearly document the behavior, so pub can use it correctly (if this behavior does have a real use case).
- Or, we should change the implementation to make sure it fires on page load.
- Deprecate
amp-pixel, and move users toamp-analytics.
I think we should go with 2), as I don't see a use case for the current behavior.
/cc @keithwrightbos @tdrl
/cc @rudygalfi
My understanding of amp-pixel's behavior is (2): It fires when the page becomes visible (page load).
@cramforce Was it ever intended that amp-pixel would be tied to layout and thus fire late or not at all?
Yes, amp-pixel is part of layout because of resource scheduling. People typically make them "always load" by making the pixel fixed position in the root element.
@cramforce - amp.css appears to ensure position fixed, top 0 so I assume no action is necessary ensure to proper behavior (assuming no style important overrides), correct? amp-pixel { /* Fixed to make position independent of page other elements. / position: fixed !important; top: 0 !important; width: 1px !important; height: 1px !important; / Only things with height are ever loaded. */ overflow: hidden !important; visibility: hidden; }
On Mon, Nov 28, 2016 at 8:12 PM Malte Ubl [email protected] wrote:
Yes, amp-pixel is part of layout because of resource scheduling. People typically make them "always load" by making the pixel fixed position in the root element.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ampproject/amphtml/issues/6246#issuecomment-263446491, or mute the thread https://github.com/notifications/unsubscribe-auth/ABr0L4hhMp_RiVql6UiP8JPXja_vPNLAks5rC3vjgaJpZM4K23oJ .
Yeah, I think this is all working as intended, but may need docs.
Ah, missed that part. Then it's working as documented and as expected. No extra docs needed.
@lannka Can you clarify your previous comment? I agree with @cramforce that a documentation update might be good here. cc @bpaduch
The amp-pixel element is meant to be used as a typical tracking pixel - to count page views.
The current implementation works as stated in the doc: 'to count page views'. I don't think we need to talk about "layout" and "fix position" in the doc, as they're really implementation details. We can document in the code though (near the layoutCallback code of amp-pixel), to prevent people like me creating another issue :-).