4 ms·
Why not just use an event handler which sends the event to GA, and after that, follows your link? They provide a callback and everything... var outboundLink
by lpsz 11y ago
Why not just use an event handler which sends the event to GA, and after that, follows your link? They provide a callback and everything...
var outboundLink = function(url) {
ga('send', 'event', 'button', 'click', {'hitCallback':
function () {
document.location = url;
}
});
}
<a href="#" onclick="outboundLink('https://www.foo.com'); return false;">Foo</a>
See: https://developers.google.com/analytics/devguides/collection/analyticsjs/events https://developers.google.com/analytics/devguides/collection...
- NathanKP 11y agoAnd now you have a website that feels slow to respond to link clicks.
- dudus 11y agoYou can also do ga('send', 'event', 'button', 'click', {transport: 'beacon'}); This will work even after you redirect to another page but only if the browser supports navigator.sendBeacon(). Currently not IE or Safari.