This is an automated email from the ASF dual-hosted git repository.
shuai pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/answer-website.git
The following commit(s) were added to refs/heads/main by this push:
new 887e4957e fix: add matomo script tag
887e4957e is described below
commit 887e4957e341227373dcfcc4fdfbf092584c5bea
Author: shuai <[email protected]>
AuthorDate: Mon Feb 17 18:47:27 2025 +0800
fix: add matomo script tag
---
src/theme/Layout/globalHead.tsx | 23 +++++++++++++++++++++++
src/theme/Layout/index.tsx | 4 ++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/src/theme/Layout/globalHead.tsx b/src/theme/Layout/globalHead.tsx
new file mode 100644
index 000000000..64a43c1e4
--- /dev/null
+++ b/src/theme/Layout/globalHead.tsx
@@ -0,0 +1,23 @@
+import Head from '@docusaurus/Head';
+
+export default function GlobalHead() {
+ return (
+ <Head>
+ <script>{`
+ var _paq = window._paq = window._paq || [];
+ /* tracker methods like "setCustomDimension" should be called before
"trackPageView" */
+ _paq.push(["setDoNotTrack", true]);
+ _paq.push(["disableCookies"]);
+ _paq.push(['trackPageView']);
+ _paq.push(['enableLinkTracking']);
+ (function() {
+ var u="https://analytics.apache.org/";
+ _paq.push(['setTrackerUrl', u+'matomo.php']);
+ _paq.push(['setSiteId', '75']);
+ 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>
+ </Head>
+ );
+}
diff --git a/src/theme/Layout/index.tsx b/src/theme/Layout/index.tsx
index ffa65a02c..16d3c13e1 100644
--- a/src/theme/Layout/index.tsx
+++ b/src/theme/Layout/index.tsx
@@ -23,6 +23,7 @@ import LayoutProvider from '@theme/Layout/Provider';
import ErrorPageContent from '@theme/ErrorPageContent';
import type {Props} from '@theme/Layout';
import BrowserLanguage from './BrowserLanguage';
+import GlobalHead from './globalHead';
import styles from './styles.module.css';
@@ -36,13 +37,12 @@ export default function Layout(props: Props): JSX.Element {
description,
} = props;
- const location = useLocation();
-
useKeyboardNavigation();
return (
<LayoutProvider>
+ <GlobalHead />
<PageMetadata title={title} description={description} />
<SkipToContent />