Google Analytics 4 Tag
Adds the Google Analytics 4 (gtag.js) tracking code to the head of every public page.
Opens WPIDE on
Code
<!-- Google Analytics 4. Replace G-XXXXXXXXXX with your Measurement ID (two places). -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
Notes
Find your Measurement ID in Google Analytics under Admin > Data streams. G-XXXXXXXXXX is a placeholder. Check your privacy and consent obligations before enabling.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.