From 4409f330c512c664f6ce1980d5aff72d9ab3f817 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Fri, 27 Jan 2023 14:37:17 +0100 Subject: [PATCH] Move GA code directly into main page (#289) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This replaces a bit of code with the equivalent HTML code. We also load the script async, which means that the browser won’t block rendering while waiting for the scripts. --- ga4.js | 16 ---------------- theme/index.hbs | 10 ++++++++++ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/ga4.js b/ga4.js index 4ad383a5..b075cdb1 100644 --- a/ga4.js +++ b/ga4.js @@ -12,22 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Setup cookie consent banner. -var consent = document.createElement('script'); -consent.setAttribute('data-autoload-cookie-consent-bar', 'true'); -consent.setAttribute('src', 'https://www.gstatic.com/brandstudio/kato/cookie_choice_component/cookie_consent_bar.v3.js'); -document.head.appendChild(consent); - -// Load and configure Google Analytics. -var ga4 = document.createElement('script'); -ga4.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?id=G-ZN78TEJMRW'); -document.head.appendChild(ga4); - -window.dataLayer = window.dataLayer || []; -function gtag(){dataLayer.push(arguments);} -gtag('js', new Date()); -gtag('config', 'G-ZN78TEJMRW'); - // Look through all Playgrounds on the page to determine if the code snippet // matches one of the. If the code is different from all Playgrounds, we // conclude that the user modified the Playground before submitting it. diff --git a/theme/index.hbs b/theme/index.hbs index 147eb9af..b0fd3d42 100644 --- a/theme/index.hbs +++ b/theme/index.hbs @@ -11,6 +11,16 @@ {{/if}} + + + + {{> head}}