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

Pass along document.referrer as amp_referrer query parameter during mobile redirection #5776

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/src/mobile-redirection.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
// from ensuing. See <https://github.com/ampproject/amp-wp/issues/5767>.
window.stop(); // Stop loading the page! This should cancel all loading resources.

// Pass along referrer so that amp-analytics can report the correct referrer.
if ( document.referrer ) {
amphtmlUrlObject.searchParams.set( 'amp_referrer', document.referrer );
}

// Replace the current page with the AMP version.
location.replace( amphtmlUrlObject.href );
}
Expand Down