I have a amp story where I have also implemented tracking with Google Analytics. Events such as story-page-visible are working perfectly. But when I tried to track the click event on an anchor tag inside my story page it does not work.These are my triggers and anchor tag:
UPDATED CODE
<amp-analytics type="gtag" data-credentials="include">
<script type="application/json">
{
"vars": {
"gtag_id": "UA-YYYY-Y",
"event_category": "<%= storyName %>",
"config": {
"UA-YYYY-Y": {
"groups": "default"
}
}
},
"extraUrlParams": {
"cd75": "AMP",
"cd69": "AMP",
"cd81": "marketplace",
"cd76": "${ampdocHostname}"
},
"triggers": {
"linkClick" : {
"on": "click",
"selector": "a",
"request": "event",
"vars": {
"eventCategory" : "click"
}
}
}
}
</script>
</amp-analytics>
<a href="https://amp.dev/" >
<p>click here to read more</p>
</a>
No event is fired on click of anchor tag or on click of tooltip.Any suggestions would be really helpful.
I tried your example and it seems to work. I'm posting the full configuration I used so you can compare with yours. Also, did you add the amp-analytics script in the head of your document?
--
Here you have a typo and forgot to close the
</p>
tag, but it should work nonetheless.