@@ -11,6 +11,10 @@ export default function LayoutWrapper(props: Props): ReactNode {
1111
1212 const [ trackingInitialized , setTrackingInitialized ] = useState ( false ) ;
1313
14+ // Check if cookies are disabled via query parameter
15+ const isCookieDisabled = ExecutionEnvironment . canUseDOM &&
16+ new URLSearchParams ( window . location . search ) . get ( "cookies" ) === "disabled" ;
17+
1418 const initializeGATracking = ( ) => {
1519 if ( ExecutionEnvironment . canUseDOM && ! window . gtag ) {
1620 const script = document . createElement ( "script" ) ;
@@ -33,39 +37,41 @@ export default function LayoutWrapper(props: Props): ReactNode {
3337
3438 const cookieConsent = Cookies . get ( "bitbybit-docs-cookie-consent" ) ;
3539
36- if ( cookieConsent === "true" && trackingInitialized === false ) {
40+ if ( cookieConsent === "true" && trackingInitialized === false && ! isCookieDisabled ) {
3741 initializeGATracking ( ) ;
3842 setTrackingInitialized ( true ) ;
3943 }
4044
4145 return (
4246 < >
4347 < Layout { ...props } />
44- < CookieConsent
45- location = "bottom"
46- buttonText = "ACCEPT COOKIES ❤️"
47- declineButtonText = "DECLINE"
48- cookieName = "bitbybit-docs-cookie-consent"
49- style = { { background : "#2B373B" } }
50- enableDeclineButton
51- overlay
52- flipButtons
53- buttonStyle = { { backgroundColor : "#f0cebb" , color : "#1a1c1f" , fontWeight : "bold" , fontSize : "13px" , borderRadius : "5px" , padding : "10px 20px" } }
54- declineButtonStyle = { { backgroundColor : "#1a1c1f" , color : "#f0cebb" , fontWeight : "bold" , fontSize : "13px" , borderRadius : "5px" , padding : "10px 20px" } }
48+ { ! isCookieDisabled && (
49+ < CookieConsent
50+ location = "bottom"
51+ buttonText = "ACCEPT COOKIES ❤️"
52+ declineButtonText = "DECLINE"
53+ cookieName = "bitbybit-docs-cookie-consent"
54+ style = { { background : "#2B373B" } }
55+ enableDeclineButton
56+ overlay
57+ flipButtons
58+ buttonStyle = { { backgroundColor : "#f0cebb" , color : "#1a1c1f" , fontWeight : "bold" , fontSize : "13px" , borderRadius : "5px" , padding : "10px 20px" } }
59+ declineButtonStyle = { { backgroundColor : "#1a1c1f" , color : "#f0cebb" , fontWeight : "bold" , fontSize : "13px" , borderRadius : "5px" , padding : "10px 20px" } }
5560
56- onAccept = { ( acceptedByScrolling ) => {
57- if ( acceptedByScrolling ) {
58- // triggered if user scrolls past threshold
59- } else {
60- initializeGATracking ( ) ;
61- }
62- } }
63- >
64- < h2 > Help us improve Bitbybit</ h2 >
65- < p >
66- To help us improve Bitbybit and its documentation, we’d like to use Google Analytics, which requires setting cookies. Do you consent to this?
67- </ p >
68- </ CookieConsent >
61+ onAccept = { ( acceptedByScrolling ) => {
62+ if ( acceptedByScrolling ) {
63+ // triggered if user scrolls past threshold
64+ } else {
65+ initializeGATracking ( ) ;
66+ }
67+ } }
68+ >
69+ < h2 > Help us improve Bitbybit</ h2 >
70+ < p >
71+ To help us improve Bitbybit and its documentation, we’d like to use Google Analytics, which requires setting cookies. Do you consent to this?
72+ </ p >
73+ </ CookieConsent >
74+ ) }
6975 </ >
7076 ) ;
7177}
0 commit comments