I would like to track whether a toast (or any "pop-up") will be displayed using Google Analytics event tracking through GTM. Whether the toast is displayed or not is determined by the jQuery code and based on such cookie information
function ShowToast(Msg){
$('#toast-msg').html(Msg);
$('#toast').animate({ left: '-10px' });
}
called up
<script type="text/javascript">
$(function() {
ShowToast("SOME HTML");
});
</script>
This is what I got in GTM so far using a user variable
function(){
if(document.querySelector("#toast #toast-msg").length > 0){
return true;
}
}
when a trigger listens on this variable as true and as a regular universal analytics event tag. The idea is to simply check if toast-msg is shown, which works great in preview mode.
: gtm.js( ), jQuery , gtm.js . , , , .
GTM Javascript/JQuery, , JQuery GTM-//? ?