From 6f30015d85c86ae0fd3f48e38115012421e1f746 Mon Sep 17 00:00:00 2001 From: Francois Prunayre Date: Wed, 6 Sep 2023 14:36:53 +0200 Subject: [PATCH 1/2] Analytics services integration / Send events by protocol --- .../components/metadataactions/RelatedResourcesService.js | 6 ++++-- .../resources/catalog/components/utility/UtilityService.js | 1 + web-ui/src/main/resources/catalog/views/default/module.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/web-ui/src/main/resources/catalog/components/metadataactions/RelatedResourcesService.js b/web-ui/src/main/resources/catalog/components/metadataactions/RelatedResourcesService.js index e0003aba510..11c124fb935 100644 --- a/web-ui/src/main/resources/catalog/components/metadataactions/RelatedResourcesService.js +++ b/web-ui/src/main/resources/catalog/components/metadataactions/RelatedResourcesService.js @@ -133,6 +133,7 @@ var addWFSToMap = function (link, md) { var url = $filter("gnLocalized")(link.url) || link.url; + gnWebAnalyticsService.trackLink(url, link.protocol); var isServiceLink = gnSearchSettings.mapProtocols.services.indexOf(link.protocol) > -1; @@ -209,6 +210,7 @@ function addMapToMap(record, md) { var url = $filter("gnLocalized")(record.url) || record.url; + gnWebAnalyticsService.trackLink(url, record.protocol); gnOwsContextService.loadContextFromUrl(url, gnSearchSettings.viewerMap); gnSearchLocation.setMap("legend"); @@ -248,11 +250,11 @@ var openLink = function (record, link) { var url = $filter("gnLocalized")(record.url) || record.url; if (url && angular.isString(url) && url.match("^(http|ftp|sftp|\\\\|//)")) { - gnWebAnalyticsService.trackLink(url, "link"); + gnWebAnalyticsService.trackLink(url, record.protocol); return window.open(url, "_blank"); } else if (url && url.indexOf("www.") == 0) { - gnWebAnalyticsService.trackLink("http://" + url, "link"); + gnWebAnalyticsService.trackLink("http://" + url, record.protocol); return window.open("http://" + url, "_blank"); } else if ( diff --git a/web-ui/src/main/resources/catalog/components/utility/UtilityService.js b/web-ui/src/main/resources/catalog/components/utility/UtilityService.js index 93937d5c6bf..a321e2a71a1 100644 --- a/web-ui/src/main/resources/catalog/components/utility/UtilityService.js +++ b/web-ui/src/main/resources/catalog/components/utility/UtilityService.js @@ -926,6 +926,7 @@ // Implement track link for the analytics if (analyticsService === "matomo") { _paq.push(["trackLink", url, linkType]); + _paq.push(["trackEvent", "catalogue-actions", linkType, url]); } }; } diff --git a/web-ui/src/main/resources/catalog/views/default/module.js b/web-ui/src/main/resources/catalog/views/default/module.js index 4aebaccf3d5..da63ddcee18 100644 --- a/web-ui/src/main/resources/catalog/views/default/module.js +++ b/web-ui/src/main/resources/catalog/views/default/module.js @@ -419,7 +419,7 @@ addMdLayerToMap: function (link, md) { var config = buildAddToMapConfig(link, md); - gnWebAnalyticsService.trackLink(config.url, config.type); + gnWebAnalyticsService.trackLink(config.url, link.protocol); // This is probably only a service // Open the add service layer tab From 628010fb3c23a3e0302d70380e50b7467c3b438f Mon Sep 17 00:00:00 2001 From: Francois Prunayre Date: Wed, 6 Sep 2023 14:37:52 +0200 Subject: [PATCH 2/2] Analytics services integration / Add example config for matomo. --- web/src/main/webResources/WEB-INF/config.properties | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/src/main/webResources/WEB-INF/config.properties b/web/src/main/webResources/WEB-INF/config.properties index 0e8965fa6c2..a6a03909248 100644 --- a/web/src/main/webResources/WEB-INF/config.properties +++ b/web/src/main/webResources/WEB-INF/config.properties @@ -60,3 +60,8 @@ db.migration_onstartup=true analytics.web.service= # Analytics javascript code to integrate with the analytics service (lines must be ended with \n\) analytics.web.jscode= + +#analytics.web.service=matomo +#analytics.web.jscode=var _paq = _paq || [];_paq.push(['trackPageView']);_paq.push(['enableLinkTracking']);(function() {var u="//localhost/";_paq.push(['setTrackerUrl', u+'piwik.php']);_paq.push(['setSiteId', '1']);var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);})();var currentUrl = location.href; \ +#window.addEventListener('hashchange', function() {_paq.push(['setReferrerUrl', currentUrl]);currentUrl = window.location.hash.substr(1);_paq.push(['setCustomUrl', currentUrl]);_paq.push(['setDocumentTitle', currentUrl]);_paq.push(['deleteCustomVariables', 'page']);_paq.push(['trackPageView']);var content = document.getElementsByTagName('body')[0];_paq.push(['MediaAnalytics::scanForMedia', content]);_paq.push(['FormAnalytics::scanForForms', content]);_paq.push(['trackContentImpressionsWithinNode', content]);_paq.push(['enableLinkTracking']);}); +