How to install the new Google Analytics 4 code to your site? #248
Replies: 5 comments 8 replies
-
|
I just stumbled across this. I use a different template ( |
Beta Was this translation helpful? Give feedback.
-
|
I was trying and trying and it wasn't working until I noticed I was using Brave browser to test my site. Lol |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Should the documentation be updated to the Hugo doc services? Currently it is like this https://github.com/adityatelange/hugo-PaperMod/wiki/Installation: analytics:
google:
SiteVerificationTag: "XYZabc"
bing:
SiteVerificationTag: "XYZabc"
yandex:
SiteVerificationTag: "XYZabc"And seems to not work... |
Beta Was this translation helpful? Give feedback.
-
|
Along with the below config in
services:
googleAnalytics:
id: G-XXXXXXXXXX
instagram:
disableInlineCSS: true
twitter:
disableInlineCSS: true
|
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Google Analytics is now using the new
gtag.jstracking code. But Hugo's internal GA template doesn't work with the new code yet. So, I just wanted to give a heads up to people who're not sure how to get it to work.The code looks something like this -
G-XXX012XXYY. And updating theconfig.yamlwith that code instead of the olderUA-XXX012XXYYwouldn't work. Fortunately & thanks for @adityatelange's forward thinking, you can easily integrate the new code with ease.So, here's how you do it.
Ensure you've updated your
config.ymlis updated with the new code. So, replace the older value ofGoogleAnalyticsIDwith the newG-XXX012XXYY.Copy & paste the following
gtag.jssnippet intoextend_head.html:Ensure your browser isn't blocking any JavaScript & tracking cookies while running the
hugo serverin the background. Check your site loads properly onlocalhost:1313& you should see something similar to the image below on your Google Analytics dashboard.Beta Was this translation helpful? Give feedback.
All reactions