Skip to content

Commit

Permalink
migrated analytics to GA4
Browse files Browse the repository at this point in the history
  • Loading branch information
anvaka committed Apr 27, 2023
1 parent 99f8fd6 commit 4d1979a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
17 changes: 9 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-TXT6313TGG"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-TXT6313TGG');
</script>
<meta property="og:title" content="Draw all roads in any city at once" />
<meta property="og:image" content="https://i.imgur.com/Fbbe5a6.png" />
<meta property="og:description" content="This website allows you to select a city and then draws every single road on a screen." />
Expand Down Expand Up @@ -48,13 +56,6 @@
<div id="host"></div>

<script type="module" src="/src/main.js"></script>
<script>
(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-47259320-1', 'anvaka.github.io');
ga('send', 'pageview');
</script> </body>
</body>

</html>
11 changes: 5 additions & 6 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,12 @@ function toRGBA(c) {
}
function recordOpenClick(link) {
if (typeof ga === 'undefined') return;
if (typeof gtag === 'undefined') return;
ga('send', 'event', {
eventCategory: 'Outbound Link',
eventAction: 'click',
eventLabel: link
});
gtag('event', 'click', {
'event_category': 'Outbound Link',
'event_label': link
});
}
</script>

Expand Down
8 changes: 4 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ if (isWebGLEnabled(document.querySelector('#canvas'))) {
}

function logError(e) {
if (typeof ga !== 'function') return;
if (typeof gtag !== 'function') return;

const exDescription = e ? `${e.message} in ${e.filename}:${e.lineno}` : 'Unknown exception';

ga('send', 'exception', {
exDescription,
exFatal: false
gtag('send', 'exception', {
description: exDescription,
fatal: false
});
}

0 comments on commit 4d1979a

Please sign in to comment.