Skip to content

Commit

Permalink
Merge pull request #213 from rstudio/fix/ex-181-gtag
Browse files Browse the repository at this point in the history
  • Loading branch information
gadenbuie authored Aug 3, 2023
2 parents e9bfbf2 + 07dc2df commit c7bf00d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions 181-google-analytics/google-analytics.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-160622973-1"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=GT-XXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'UA-160622973-1');
gtag('config', 'GT-XXXXXX');

$(document).on('change', 'select', function(e) {
ga('send', 'event', 'widget', 'select data', $(e.currentTarget).val());
gtag('event', 'widget', {
action: 'select data',
label: $(e.currentTarget).val()
});
});

$(document).on('click', 'button', function() {
ga('send', 'event', 'button', 'plot data');
gtag('event', 'button', { action: 'update plot' });
});
</script>

0 comments on commit c7bf00d

Please sign in to comment.