Skip to content

Commit

Permalink
matomo: add code snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
ntarocco authored and zzacharo committed Dec 16, 2024
1 parent 5116acd commit e326951
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
7 changes: 6 additions & 1 deletion invenio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ APP_DEFAULT_SECURE_HEADERS = {
"'unsafe-inline'", # for inline scripts and styles
"blob:", # for pdf preview
"cdnjs.cloudflare.com",
# Add your own policies here (e.g. analytics)
# For CERN Matomo
"webanalytics.web.cern.ch",
"test-matomo-wf.web.cern.ch",
],
},
'content_security_policy_report_only': False,
Expand Down Expand Up @@ -137,6 +139,9 @@ THEME_SITENAME = 'CDS'
# THEME_FOOTER_TEMPLATE = 'cds_rdm/footer.html'
# THEME_HEADER_TEMPLATE = 'cds_rdm/header.html'

# Site tracking code template for matomo analytics
# Enable the below on the dedicated environment
THEME_TRACKINGCODE_TEMPLATE = "cds_rdm/matomo-test.html"

# Invenio-App-RDM
# ===============
Expand Down
15 changes: 15 additions & 0 deletions site/cds_rdm/templates/semantic-ui/cds_rdm/matomo-prod.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://webanalytics.web.cern.ch/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '756']);
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>
<!-- End Matomo Code -->
15 changes: 15 additions & 0 deletions site/cds_rdm/templates/semantic-ui/cds_rdm/matomo-test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://test-matomo-wf.web.cern.ch/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '325']);
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>
<!-- End Matomo Code -->

0 comments on commit e326951

Please sign in to comment.