The documentation you refer to is mostly for vendors and developers of analytics products. If you are using snowplow v2 and not doing it from scratch. I recommend using this documentation:
As far as I remember from working on v2, curly braces are special constructs in AMP and AMP treats variables in triggers differently than in vars. AMP has very bad documentation around this, it took a while for us to figure it out when working on v2.
Try removing first set of braces and moving the compound moving value to vars then using that var instead (i.e.):
<amp-analytics type="snowplow_v2" id="event1">
<script type="application/json">
{
"vars": {
"collectorHost": "snowplow-collector.acme.com", // Replace with your collector host
"appId": "campaign-microsite", // Replace with your app ID
"customLabel": "this_should_be_test_value: ${test}"
},
"triggers": {
"trackMyCustomEventClick": {
"on": "click",
"selector": "a"
"request": "structEvent",
"vars": {
"structEventCategory": "CTA",
"structEventAction": "my_action",
"structEventLabel": "${customLabel}"
}
}
}
}
</script>
</amp-analytics>
You can also follow the example in AMP Git repo when working on your implementation:
Unfortunately AMP could be very frustrating, mostly due to poor/unorganized documentation when it comes to amp-analytics and a lot of undocumented/unreferenced restrictions. I do not have ability to spin off a local AMP testing environment now and don’t quite remember how this could be resolved off top of my head. I’ll take a look in the evening once I am done with work. In the meantime, I suggest trying the following:
<amp-analytics type="snowplow_v2" id="event1">
<script type="application/json">
{
"vars": {
"collectorHost": "snowplow-collector.acme.com", // Replace with your collector host
"appId": "campaign-microsite" // Replace with your app ID
},
"triggers": {
"trackMyCustomEventClick": {
"on": "click",
"selector": "a"
"request": "structEvent",
"vars": {
"structEventCategory": "CTA",
"structEventAction": "my_action",
"structEventLabel": "this_should_be_test_value: ${test}"
}
}
}
}
</script>
</amp-analytics>
and this:
<amp-analytics type="snowplow_v2" id="event1">
<script type="application/json">
{
"vars": {
"collectorHost": "snowplow-collector.acme.com", // Replace with your collector host
"appId": "campaign-microsite" // Replace with your app ID
},
"triggers": {
"trackMyCustomEventClick": {
"on": "click",
"selector": "a"
"request": "structEvent",
"vars": {
"structEventCategory": "CTA",
"structEventAction": "my_action",
"structEventLabel": "this_should_be_test_value: `${test}`"
}
}
}
}
</script>
</amp-analytics>
or this:
<amp-analytics type="snowplow_v2" id="event1">
<script type="application/json">
{
"vars": {
"collectorHost": "snowplow-collector.acme.com", // Replace with your collector host
"appId": "campaign-microsite" // Replace with your app ID
},
"triggers": {
"trackMyCustomEventClick": {
"on": "click",
"selector": "a"
"request": "structEvent",
"vars": {
"structEventCategory": "CTA",
"structEventAction": "my_action",
"structEventLabel": "this_should_be_test_value: $REPLACE(`${test}`, `.+`,`${test}`)"
}
}
}
}
</script>
</amp-analytics>