I'm really bad at web in general, but it seems I'm to do a study on AMP :x
While I managed to send data in-house using amp-analytics I am also trying to display a "privacy popup" and get the user choices to forward them to our analytic tools.
I've tried actually several things, using amp-state and trying to bind to send data with a binding. Tried to override variables declared in my amp-analytics (which worked in one shot with data-vars-name, but don't set any value)
<amp-analytics id="testlytics">
<script type="application/json">
{
"vars": {
"container_id": "2",
"page_name" : "amp_homepage",
"user_id" : "",
"order_id" : "",
"privacy" : "",
},
"requests": {
"baseURL": "https://baseurl.com/${container_id}/?privacy=${privacy}",
"pageTrack": "${baseURL}&page_name=${page_name}&user_id=${user_id}&order_id=${order_id}",
"eventTrack": "${pageTrack}&scrollY=${scrollTop}&scrollX=${scrollLeft}&height=${availableScreenHeight}&width=${availableScreenWidth}&scrollBoundV=${verticalScrollBoundary}&scrollBoundH=${horizontalScrollBoundary}&eventLabel=${eventlabel}"
},
"triggers": {
"pageview": {
"on": "visible",
"request": "pageTrack",
"vars": {
"type": "page"
}
},
"clickPings": {
"selector": ".events",
"on": "click",
"request": "eventTrack",
"vars": {
"type": "event"
}
}
}
}
</script>
</amp-analytics>
Among my tests was :
<span id="event-test" class="events" data-vars-container_id="3311">
Click here to generate an event
</span>
<span id="event-test" class="events">
Click here to generate an event that doesn't override container_id
</span>
Which kinda works for events like button click, but can't be used to set a variable for the entire navigation and more.
I also tried using:
<amp-state id="privacy_state">
<script type="application/json">
{
"tag_list": "12"
}
</script>
</amp-state>
<amp-user-notification
id="my-notification"
layout="nodisplay">
This is an amp-user-notification. It uses local storage to store the dismissed state.
<button on="tap:AMP.setState({tag_list: '3'})">Change privacy state</button>
<button on="tap:my-notification.dismiss">I accept</button>
</amp-user-notification>
But I can't seem to be able to use what's inside the amp-state inside my amp-analytics anyway.
Does anyone know the best way to do this? Should I write with my popup in the local storage and then how to read this and send it to my server?
Thank you for helping ! :)