Reputation: 93
Would it be possible to dynamically change values within an AMP page based on URL parameters passed through to the page?
I have a need for creating multiple pages, more than 20, and I'm wondering if I can just dynamically change parts of the page to solve that issue. Only a few things need to change within it.
Upvotes: 1
Views: 1495
Reputation: 291
I think that the question is bit ambiguous so I will try and answer what I get from it.
Are you taking about dynamic changes using JavaScript No, Its not possible as AMP is very restricted for custom JavaScript, As a alternative you can make the page dynamic at server side (Using PHP, Node, Java or whatever you are using )
For tracking purposes Yes you can pass dynamic data to tracking libraries. Use Google tag manager for hassle free integration of most tracking API calls. Tag manager provides URL variables build in to help you read them, For other dynamic variables just pass them in a JSON
<amp-analytics config="https://www.googletagmanager.com/amp.json?id=<your id here>&gtm.url=SOURCE_URL" data-credentials="include" class="i-amphtml-element i-amphtml-layout-fixed i-amphtml-layout-size-defined i-amphtml-layout" style="width: 1px; height: 1px; display: none;" aria-hidden="true">
<script type="application/json">
{
"vars":{"buyer_preference":null,"res_com":"R"}
}
</script>
</amp-analytics>
Upvotes: 1