diff --git a/webui/src/components/record.jsx b/webui/src/components/record.jsx
index 4ed72737f..cdde95b32 100644
--- a/webui/src/components/record.jsx
+++ b/webui/src/components/record.jsx
@@ -131,6 +131,16 @@ const Record = React.createClass({
return state;
},
+ catchMatomoEvent(event) {
+ event.stopPropagation();
+ event.preventDefault();
+ if (window._paq) {
+ const metadata = this.props.record.get('metadata') || Map();
+ const doi = metadata.get('DOI').replace("http://doi.org/", "");
+ window._paq.push(['trackEvent', 'b2share', event.type, doi]);
+ }
+ },
+
getB2Notes(host, target, pids, sources) {
var self = this;
@@ -158,11 +168,12 @@ const Record = React.createClass({
},
componentDidMount() {
+ this.catchMatomoEvent(new Event("recordview"));
+
// this is set async in parent
if (this.state.b2noteUrl == "") {
return;
}
-
window.addEventListener('message', this.catchB2NoteEvent);
this.updateNotes();
@@ -353,7 +364,7 @@ const Record = React.createClass({
if (b2noteUrl) {
b2noteWidget = ;
}
- return
+ return
}
fileComponent =
@@ -501,13 +512,6 @@ const Record = React.createClass({
);
},
- componentDidMount() {
- const record = this.props.record;
- const metadata = record.get('metadata') || Map();
- const doi = metadata.get('DOI').replace("http://doi.org/", "");
- window._paq.push(['trackEvent', 'b2share', 'recordview', doi]);
- },
-
render() {
const rootSchema = this.props.rootSchema;
const blockSchemas = this.props.blockSchemas;
diff --git a/webui/src/main.jsx b/webui/src/main.jsx
index 5f60db7f0..c216769e2 100644
--- a/webui/src/main.jsx
+++ b/webui/src/main.jsx
@@ -34,7 +34,7 @@ import { CommunityAdmin } from './components/community_admin.jsx'
const piwik = process.env.B2SHARE_WEBUI_MATOMO_URL && process.env.B2SHARE_WEBUI_MATOMO_SITEID ?
PiwikReactRouter({
url: process.env.B2SHARE_WEBUI_MATOMO_URL,
- siteId: process.env.B2SHARE_WEBUI_MATOMO_SITEID
+ siteId: process.env.B2SHARE_WEBUI_MATOMO_SITEID,
}) : false;
const AppFrame = React.createClass({