From 66c8edf0ef4a71944eb3708f39101c0ea17c1d07 Mon Sep 17 00:00:00 2001 From: Aaron Adler Date: Wed, 7 Dec 2022 20:33:23 -0500 Subject: [PATCH] Move Google Analytics script to the Google cannot read the Google Analytics script if it is placed at the bottom of the . It can only be read when it's placed here in the This has been documented by other NextJS users online, and by Google themselves, which directs users to place the script in the head. Hope this helps NextJS users! --- examples/with-google-analytics/pages/_document.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/with-google-analytics/pages/_document.js b/examples/with-google-analytics/pages/_document.js index db3c34b900d5b84..132664aee3d45da 100644 --- a/examples/with-google-analytics/pages/_document.js +++ b/examples/with-google-analytics/pages/_document.js @@ -3,11 +3,7 @@ import { Html, Head, Main, NextScript } from 'next/document' export default function Document() { return ( - - -
- - + {/* Global Site Tag (gtag.js) - Google Analytics */}