Pass along document.referrer as amp_referrer query parameter during mobile redirection #5776
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
When client-side (JS-based) mobile redirection is enabled (which is the default instead of server-side redirection), any amp-analytics that runs on the resulting page will no longer be able to see the the
Referrer
, resulting in erroneous reports of direct traffic. See support topic.I think we can rectify this by passing along the referrer in a query parameter, like
amp_referrer
. With the original referrer then on the destination page, it is then available to be passed along toamp-analytics
. I believe this can be done by explicitly declaring thereferrer
in thevars
for an analytics config as follows:Here it attempts to pass
amp_referrer
query parameter as thereferrer
, or if that is not available it falls back to the document referrer. I'm not sure if the above is correct or if it should be:See amp-analytics variables and AMP HTML URL Variable Substitutions.
We could modify all
amp-analytics
on the page to inject thisreferrer
when JS-based mobile redirection is enabled, or we could defer to the user to enable that instead such as via a plugin that filtersamp_analytics_entries
.Checklist