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

Analytics improvements #84

Merged
merged 2 commits into from
Sep 6, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion web-ui/src/main/resources/catalog/views/default/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions web/src/main/webResources/WEB-INF/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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']);});

Loading