Reputation: 35
I am trying to fire a tracking event when an option is selected inside a <select>
tag.
With amp-analytics
I am able to send a click
tracking event when an element is clicked, but only with certain elements like <select>
<a>
and <div>
.
I can understand why a click event wouldn't be fired on an <option>
element but I was wondering how to track that an option was selected. Below is my code that will fire on the click of the <select>
but not on the click of an <option>
<body>
<select>
<option>option 1</option>
<option>option 2</option>
</select>
<amp-analytics>
<script type="application/json">
{
"requests": {
"event": "https://www.example.com?message=${message}"
},
"triggers": {
"selectClicked": {
"on": "click",
"request": "event",
"selector": "select",
"vars": {
"message": "clicked_select"
}
},
"optionClicked": {
"on": "click",
"request": "event",
"selector": "option",
"vars": {
"message": "clicked_option"
}
}
}
}
</script>
</amp-analytics>
</body>
It looks amp-analytics only supports a couple Triggers:
render-start
ini-load
click
scroll
timer
visible
hidden
user-error
access-*
video-*
Any help would be greatly appreciated, Thanks
Upvotes: 0
Views: 436