Skip to content

Commit

Permalink
add matomo tag manager code snippet and add id for tracking organisat…
Browse files Browse the repository at this point in the history
…ional publication views
  • Loading branch information
finlay-jisc committed Jan 21, 2025
1 parent 99f732b commit 73f126d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ui/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const isLocal = process.env.NODE_ENV === 'development';
const CSPDirectives = [
"default-src 'none';",
`script-src 'self' https://live.matomo.jisc.ac.uk ${isLocal ? "'unsafe-eval'" : ''};`,
`script-src 'self' https://live.matomo.jisc.ac.uk 'sha256-i6f/49srVFuOjNVfFr0wuerEVL1EPOoBwnrjWDUm1UA=' ${isLocal ? "'unsafe-eval'" : ''};`,
"style-src 'self' 'unsafe-inline';",
`connect-src 'self' https://*.api.octopus.ac http://127.0.0.1:4003 https://api.octopus.ac https://api.ror.org https://cdn.contentful.com https://live.matomo.jisc.ac.uk;`,
`img-src https: data: ${isLocal ? 'http:' : ''};`,
Expand Down
11 changes: 11 additions & 0 deletions ui/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect } from 'react';
import Head from 'next/head';
import { PagesProgressBar as NextProgressBar } from 'next-nprogress-bar';
import Script from 'next/script';

import * as SWR from 'swr';
import * as Framer from 'framer-motion';
Expand Down Expand Up @@ -45,6 +46,16 @@ const App = ({ Component, pageProps }: Types.AppProps<CustomProps>) => {
content="Free, fast and fair: the global primary research record where researchers publish their work in full detail."
/>
</Head>
<Script>
{`
var _mtm = window._mtm = window._mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
(function() {
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='https://live.matomo.jisc.ac.uk/js/container_WL3HjWKp.js'; s.parentNode.insertBefore(g,s);
})();
`}
</Script>

<NextProgressBar
color="#348cb1"
Expand Down
9 changes: 8 additions & 1 deletion ui/src/pages/publications/[id]/versions/[versionId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,14 @@ const Publication: Types.NextPage<Props> = (props): React.ReactElement => {
: undefined
}
>
<section className="col-span-12 lg:col-span-8 xl:col-span-9">
<section
id={
publicationVersion.user.role === 'ORGANISATION'
? `organisation-${publicationVersion.user.id}-publication`
: undefined
}
className="col-span-12 lg:col-span-8 xl:col-span-9"
>
{alerts}
{showApprovalsTracker && (
<>
Expand Down

0 comments on commit 73f126d

Please sign in to comment.