I would like to track an onclick
of a button on a page on a site, after a condition is passed checking if a cookie is present.
Very simple but which syntax would work best?
I have researched the ga
and gaq_push
prefix of the GA event tracking syntax and (forgive me if I'm wrong) but they seem pretty similar?
_gaq.push
<script type="text/javascript">
jQuery(document).ready(function () {
if (jQuery.cookie('entry_winagrand_cookie') !== null) {
jQuery('notregisterbtn').on('click', function () {
_gaq.push(['_trackEvent', 'QR_Win_A_Grand', 'Clicked through to Register']);
});
}
});
</script>
ga
<script type="text/javascript">
jQuery(document).ready(function () {
if (jQuery.cookie('entry_winagrand_cookie') !== null) {
jQuery('notregisterbtn').on('click', function () {
ga('send', 'event', 'button', 'click', 'QR_Win_A_Grand', 'Clicked_through_to_register');
});
}
});
</script>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…