Skip to content

Commit

Permalink
docs: migrate to GA4
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Apr 17, 2023
1 parent 3ecdcff commit 4713ff6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 51 deletions.
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ subtitle: Booru browsing made easy
description: Very customizable imageboard/booru browser and mass downloader, with powerful filenaming features.
logo: assets/img/icon.png
show_download: true
google_analytics: UA-22768717-4
google_analytics: G-MR404DPTE5
discord_url: https://discord.gg/pWnY5eW3rz
theme:
lang: en_US
Expand Down
60 changes: 10 additions & 50 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,62 +12,22 @@
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
{% seo title=false %}

{% if site.google_analytics %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ site.google_analytics }}');
</script>
{% endif %}
</head>
<body {%- if layout.class %} class="{{ layout.class }}"{% endif %}>
{{ content }}

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.0.47/jquery.fancybox.min.js" integrity="sha256-MXT+AJD8HdXQ4nLEbqkMqW3wXXfvjaGQt/Q/iRlBNSU=" crossorigin="anonymous"></script>
<script src="{{ '/assets/js/main.js?v=' | append: site.github.build_revision | relative_url }}"></script>
{% if site.google_analytics %}
<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','https://www.google-analytics.com/analytics.js','ga');

ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');

var baseURI = window.location.host;
$('a').on('click', function(event) {
var th = $(this);
if (th.hasClass('fancybox')) {
return;
}

var name = th.attr('data-label') ? th.data('label') : th.html();
var href = th.attr('href');

if (href.indexOf(baseURI) === -1) {
var redir = false;
function loadPage() {
if (redir) return;
redir = true;
document.location = href;
}

var targ = th.attr('target');
var target = (targ && !targ.match(/^_(self|parent|top)$/i)) ? targ : false;
if (event.ctrlKey || event.shiftKey || event.metaKey || event.which == 2) {
target = '_blank';
}

var opts = {
'hitType': 'event',
'eventCategory': 'Outbound',
'eventAction': href,
'eventLabel': name ? name.toLowerCase() : href
};
if (!target) {
opts['hitCallback'] = loadPage;
setTimeout(loadPage, 1000);
}

ga('send', opts);
}
});
</script>
{% endif %}
</body>
</html>

0 comments on commit 4713ff6

Please sign in to comment.