Amphtml: amp-story: Support referrer override and personalized page attachment content

Created on 24 Feb 2020  路  4Comments  路  Source: ampproject/amphtml

Describe the new feature or change to an existing feature you'd like to see

I would like amp.travel to be added to the list of trusted viewers. This viewer will only be serving stories hosted on amp.travel.

https://github.com/ampproject/amphtml/blob/82cce8211345c5012ac76e81d6a80c712753f13f/src/config.js#L51-L63

Describe alternatives you've considered

N/A

Additional context

I'm trying to use a couple features that only trusted viewers are allowed to do (overriding referrer and intercepting XHR).

For overriding referrer, I'm trying to set up GA cross-domain linking for clients that link to their stories in our viewer. Since GA uses referrer to tell if it should do linking, it's currently not possible to make analytics inside of stories do the site linking when they're inside our viewer.

For intercepting XHR, I'm trying to populate the page attachment with related stories based on the user's interests and the context of the viewer they're in. Upon clicking one, I want the viewer to intercept the request and handle the story navigation itself.

Feature Request stories

Most helpful comment

+1 that these should not be coupled to the "trusted viewers".

All 4 comments

I'm trying to set up GA cross-domain linking for clients that link to their stories in our viewer. Since GA uses referrer to tell if it should do linking, it's currently not possible to make analytics inside of stories do the site linking when they're inside our viewer.

Sorry, I'm not sure I follow. Just to clarify: when a link from document A (the story) to document B (any other page) is clicked, you would like to report the referrer as amp.travel (rather than document A)? Or is this needed for reporting when tapping/swiping between stories?

I'm trying to populate the page attachment with related stories based on the user's interests and the context of the viewer they're in. Upon clicking one, I want the viewer to intercept the request and handle the story navigation itself.

This doesn't seem like it should need a trusted viewer. We should be able to achieve this with just <amp-list> and AMP actions. There may be some changes needed, but they should be safer and easier changes than adding a trusted viewer.

Sorry, I'm not sure I follow. Just to clarify: when a link from document A (the story) to document B (any other page) is clicked, you would like to report the referrer as amp.travel (rather than document A)? Or is this needed for reporting when tapping/swiping between stories?

My use case is when a link from document A (external client) goes to document B (our viewer), which then loads document C (a story) in an iframe. If I try to do GA cross domain linking from A's domain to C's domain it won't work, because C's referrer is set to B. If I could override C's referrer to set it to A (the real referrer), then the cross site linking would work.

This doesn't seem like it should need a trusted viewer. We should be able to achieve this with just <amp-list> and AMP actions. There may be some changes needed, but they should be safer and easier changes than adding a trusted viewer.

I looked into this awhile ago, and I can't quite remember what amp-list was missing in particular. I'll look through it again and get back to you.

+1 that these should not be coupled to the "trusted viewers".

I've been looking into this again. I think I'd be fine with these things not being coupled to the "trusted viewers".

I'm having a few issues with the page attachment use case though. When trying to use amp-list I get a validation error that says The tag 'template' may not appear as a descendant of tag 'amp-story-page-attachment'. Also, I can't seem to get the clicks to communicate with the viewer at all using AMP actions. Every action I try gives me an error like [Action] "AMP.saveState" is not whitelisted []., even things like A.hide. I can't seem to find any docs about this.

I have managed to do a workaround with <a rel="amphtml"> and using the a2aNavigate viewer message, but it is a bit messy for communicating context.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

choumx picture choumx  路  3Comments

torch2424 picture torch2424  路  3Comments

akshaylive picture akshaylive  路  3Comments

mkhatib picture mkhatib  路  3Comments

sryze picture sryze  路  3Comments