File tree 1 file changed +34
-0
lines changed
src/theme/NotFound/Content
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React , { JSX , useEffect } from 'react' ;
2
+ import Content from '@theme-original/NotFound/Content' ;
3
+ import type ContentType from '@theme/NotFound/Content' ;
4
+ import type { WrapperProps } from '@docusaurus/types' ;
5
+
6
+ type Props = WrapperProps < typeof ContentType > ;
7
+
8
+ export default function ContentWrapper ( props : Props ) : JSX . Element {
9
+
10
+ useEffect ( ( ) => {
11
+ if ( typeof window !== 'undefined' && window ?. gtag ) {
12
+ //normal page_view event
13
+ gtag ( "event" , "page_view" , {
14
+ page_title : "404 Not Found" ,
15
+ page_path : window . location . pathname ,
16
+ event_category : "Errors" ,
17
+ event_label : "404"
18
+ } ) ;
19
+
20
+ //custom event that might be easier to work with
21
+ window . gtag ( "event" , "not_found" , {
22
+ page_title : "Page Not Found" ,
23
+ page_path : window . location . pathname ,
24
+ event_category : "Errors" ,
25
+ event_label : "404"
26
+ } ) ;
27
+ }
28
+ } , [ ] )
29
+ return (
30
+ < >
31
+ < Content { ...props } />
32
+ </ >
33
+ ) ;
34
+ }
You can’t perform that action at this time.
0 commit comments