I implemented analytics.js (new version) in my ASPX webapplication. I got pageview working just fine, but events is very often not being send.
In my example, I tried pushing 3 different buttons, but only one of them fired the event. I added an alert-box to each event, to verify that it actually is fired, and these all show.
This is my js, placed just before the
</head>
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o), m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-XXXXXXXX-1', {
'cookieDomain': 'none'
});
ga('send', 'pageview', {
'page': '/team/main',
'title': 'Logged in'
});
$(document).ready(function() {
$(".team_button").on("click", function() {
ga('send', 'event', 'button', 'click', 'Team select button', {
'page': '/team/'
})
});
$(".calendar_month_prev").on("click", function() {
ga('send', 'event', 'button', 'click', 'Calendar: Prev month', {
'page': '/team/'
})
});
$(".calendar_month_next").on("click", function() {
ga('send', 'event', 'button', 'click', 'Calendar: Next month', {
'page': '/team/'
})
});
$(".calendar_day_selected").on("click", function() {
ga('send', 'event', 'button', 'click', 'Calendar: Same day reload', {
'page': '/team/'
})
});
$(".calendar_day_active").on("click", function() {
ga('send', 'event', 'button', 'click', 'Calendar: Select day', {
'page': '/team/'
})
});
});
I would suggest executing a dummy anchor click after successful event registration :
Since push works as a queue, your event request will never be cancelled..