I'm struggling to incorporate Google Analytics 4 to a .pug template file. (I'm new to Google Analytics and web development in general so there may be an obvious mistake I've made, but I can't find it.) I found this old thread from several years ago, and tried to use the solution with the title "2019 GTag Update" posted on August 19, 2016, but doing so did not activate GA. (I continued getting the message in my Google Analytics property that data collection wasn't active.) This is confusing because when I load the site and inspect the HTML, it appears to match up perfectly with the tagging instructions from Google Analytics.
Any help is greatly appreciated! Thanks!
head
// Google tag (gtag.js)
script(async='' src='https://www.googletagmanager.com/gtag/js?id=G-**********')
script.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-**********');
title= title