Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add analytics script #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,4 @@
of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
</p>
</div>
</div>
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
_paq.push(["disableCookies"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '42']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="https://analytics.apache.org/matomo.php?idsite=42&amp;rec=1" style="border:0;" alt="" /></p></noscript>
<!-- End Matomo Code -->
</div>
1 change: 1 addition & 0 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/site.js"></script>
<script src="/js/analytics.js"></script>
<link rel="alternate" type="application/rss+xml" title="ASF Logging Services" href="/feed.xml">
</head>
53 changes: 53 additions & 0 deletions js/analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
(function () {
// List of URLs that do not need any analytics code
const noAnalyticsUrls = [


];

// List of URLs that need a special version of Matomo code for obsolete websites
const dormantUrls = [
'https://logging.apache.org/flume',
'https://logging.apache.org/chainsaw/2.x/',
'https://logging.apache.org/log4php',
'https://logging.apache.org/log4j/1.x/',
'https://logging.apache.org/log4j/extras/',
'https://logging.apache.org/log4php/'
];

function isUrlInList(url, list) {
return list.includes(url);
}

const url = window.location.href;

if (isUrlInList(url, dormantUrls)) {
// Load Matomo code for obsolete websites
var _paq = window._paq = window._paq || [];
_paq.push(["disableCookies"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function () {
var u = "https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u + 'matomo.php']);
_paq.push(['setSiteId', '42']);
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s);
})();
} else if (isUrlInList(url, noAnalyticsUrls)) {
// Do not load any analytics code
return
} else {
var _paq = window._paq = window._paq || [];
_paq.push(["disableCookies"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function () {
var u = "https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u + 'matomo.php']);
_paq.push(['setSiteId', '42']);
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s);
})();
}
})();