Search code examples
phpseoamp-html

Does an AMP url retain the query parameters?


I've seen this question asked before but a straight answer is hard to find. I've heard both sides of the story from reliable sources. Documentation is limited but I did find this article from Google.

https://developers.google.com/amp/cache/overview#query-parameter-example

TLDR:

Query parameter example The AMP Cache URL format can also include parameters in the query string. The following is an HTTPS example with parameters: https://example-com.cdn.ampproject.org/c/s/example.com/g?value=Hello%20World

Can I use, say $_GET['utm_source'] in PHP on a page I want cached with AMP?


Solution

  • Yes, the AMP cache supports query parameters. Here is an example:

    https://ampbyexample-com.cdn.ampproject.org/c/s/ampbyexample.com/g?value=Hello%20Alice https://ampbyexample-com.cdn.ampproject.org/c/s/ampbyexample.com/g?value=Hello%20Bob

    Both links point to the same page, but render different content based on the query param. The AMP Cache mirrors this behavior.