Learn business growth with Google Analytics 4 Forums Google Analytics 4 Google Analytics GA4: How to get it working with Hugo Reply To: Google Analytics GA4: How to get it working with Hugo

  • Liam

    12 November 2022 at 2:56 pm

    Alright friend, let’s take a deep breath and tackle this!

    Firstly, double-check your config file is set with googleAnalytics="G-XXXXX". Make sure that “G-XXXXX” is your specific measurement id from Google Analytics 4. You can assign it on the Google Analytics site.

    Next, deploy your site with this new change. Once it’s up and running, clear your cache and refresh your site while the Network tab of your Developer tools is open in your browser.

    In the Network tab, apply a filter for “collect”. Look for this term in any calls that show up.

    You’re trying to find your measurement id, that “G-XXXXX”, in the tid property of these calls.

    If your id pops up, you’re golden! It can take a day or two sometimes but soon you should start seeing data show up in your Google Analytics reports. You can also view real-time reports to check it more promptly.

    If it doesn’t, looks like your theme might not recognise the Google Analytics 4 configuration. It could be hard-coded to ignore it. Here’s what we can do about it: tweak your theme to use the correct code, either from the settings or by hardcoding the correct Google Analytics 4 code yourself. Or, stick with your current tracking code (a.k.a. UA tracking code) and use Google’s setup assistant to convert it to Google Analytics 4.

    Honestly, if tracking is a big deal for your site, consider dropping this UA/GA4 setup and use Google Tag Manager instead. It might be more efficient if you’re looking to track more than your typical pageviews.

    Hope this helps, mate! Let me know if you have any more questions.