This is a little trick I’ve been using for a few years with Shopify when I want to build really interesting AJAX experiences in a theme.
Many people will tell you that accessing URL parameters is impossible, including top people at Shopify:
https://ecommerce.shopify.com/c/ecommerce-design/t/passing-query-parameters-17259
https://ecommerce.shopify.com/c/ecommerce-design/t/url-parameters-in-liquid-171887
However, it is possible! I’ve been using a technique to capture header information that is the same as Jason over @ FreakDesign but since his code is a bit cleaner with comments, I’ve opted to use his version for this tutorial. PS, if you’ve never seen his GitHub repo, check it out, there is a treasure trove of information.
Go into the HTML/CSS Editor and click add a new template.
Paste in this code.
Your URL will be something similar to this. Now you can replace the “test_tag” value with your tag and get all products and variants for that tag.
/pages/test-api?tag=test_tag&cache=false
You can do something similar to what Amazon does when loading recommending product and build other unique AJAX experiences.