Add Google Analytics 4 to EmDash
This guide adds the Google Analytics 4 tag (gtag.js) to every public page of your EmDash site. You
don’t edit your theme or redeploy.
You need: the Header & Footer Code plugin installed, an EmDash Admin account, and a GA4 property.
1. Get your measurement ID
Section titled “1. Get your measurement ID”In Google Analytics, open Admin → Data streams, choose your web stream (or create one for your
site’s URL), and copy the Measurement ID. It looks like G-XXXXXXXXXX.
2. Add the snippet in EmDash
Section titled “2. Add the snippet in EmDash”-
In the EmDash admin, open Header & Footer Code and choose New snippet.
-
Paste the tag into Code, replacing both
G-XXXXXXXXXXwith your measurement ID:<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> -
Under Settings, use these values:
Setting Value Name Google Analytics 4 Placement Head Priority 10 Enabled On -
Leave Targeting empty so the tag runs on every page.
-
Save. The tag is live within about a second.
3. Check that it works
Section titled “3. Check that it works”- View the page source of your home page (not the DOM inspector) and search for your
G-ID. If it’s not there, see Troubleshooting. - In Google Analytics, open Reports → Realtime and visit your site in another tab. Your visit should show up within a minute.
- If your pages are served from an edge HTML cache, purge it first. See Caching.
Options
Section titled “Options”- Keep staff out of your data: the plugin never outputs snippets on
/_emdash/admin pages, so admin browsing isn’t tracked. To leave out other pages, add them to Exclude paths. - Track only some sections: add include paths such as
/blogand/blog/*. See Targeting pages. - Consent: in regions that need consent before analytics cookies are set, load a consent banner and Google consent mode defaults first. See Add a cookie consent banner.
Common problems
Section titled “Common problems”| Symptom | Fix |
|---|---|
| No data in Realtime | Check the ID in both places, the snippet is On, and the layout renders <EmDashHead />. |
| Page views counted twice | GA4 is also installed through GTM or the theme. Keep one. |
| Works on some pages only | Clear Include paths, or check Page kind is All pages. |
© 2026 Jithin Sebastian ·MIT License ·GitHub