Skip to content

Instantly share code, notes, and snippets.

@goosmurf
Created January 9, 2020 04:31
Show Gist options
  • Save goosmurf/9fec28db0e9747baa70a0120af59e389 to your computer and use it in GitHub Desktop.
Save goosmurf/9fec28db0e9747baa70a0120af59e389 to your computer and use it in GitHub Desktop.
<html>
<head>
<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-457690-7', 'auto');
//ga('set', 'transport', 'beacon');
ga('send', 'pageview');
// This is correct
ga('send', 'event', {
eventCategory: 'Test',
eventAction: 'action',
eventLabel: 'Working beacon',
transport: 'beacon'
});
// This doesn't work; if you check your Network tab you'll see it falls
// back to using an image
ga('send', 'event',
{
eventCategory: 'Test',
eventAction: 'action',
eventLabel: 'Broken beacon',
},
{ transport: 'beacon' }
);
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics -->
</head>
<body>
Derp
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment