amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

when would amp-pixel get fired is not documented well

Open lannka opened this issue 10 years ago • 8 comments

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:

  1. Clearly document the behavior, so pub can use it correctly (if this behavior does have a real use case).
  2. Or, we should change the implementation to make sure it fires on page load.
  3. Deprecate amp-pixel, and move users to amp-analytics.

I think we should go with 2), as I don't see a use case for the current behavior.

/cc @keithwrightbos @tdrl

lannka avatar Nov 18 '16 20:11 lannka

/cc @rudygalfi

ericlindley-g avatar Nov 26 '16 20:11 ericlindley-g

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?

rudygalfi avatar Nov 29 '16 01:11 rudygalfi

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 avatar Nov 29 '16 01:11 cramforce

@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 .

keithwrightbos avatar Nov 30 '16 03:11 keithwrightbos

Yeah, I think this is all working as intended, but may need docs.

cramforce avatar Nov 30 '16 14:11 cramforce

Ah, missed that part. Then it's working as documented and as expected. No extra docs needed.

lannka avatar Nov 30 '16 17:11 lannka

@lannka Can you clarify your previous comment? I agree with @cramforce that a documentation update might be good here. cc @bpaduch

rudygalfi avatar Nov 30 '16 17:11 rudygalfi

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 :-).

lannka avatar Nov 30 '16 19:11 lannka