Use your theme's built-in header and footer code fields first, no plugin needed for most themes built in the last few years. Find them in Appearance → Customize → Theme Settings or a similar panel depending on your theme (block themes often expose this under Appearance → Editor → Theme Settings). Paste the script between the fields marked for header or footer code and save.
If your theme has no such field, use a small code-snippet plugin instead of editing theme files directly. Editing header.php or footer.php works but gets wiped out the next time the theme updates, since the update overwrites the file.
Where to paste what
Most tracking and verification tags fall into two spots:
- Header (before
</head>): Google Analytics (gtag.js), Google Search Console HTML tag verification, Meta Pixel base code, Google Tag Manager's head snippet. - Footer (before
</body>): Google Tag Manager's noscript snippet, chat widgets, and any script that isn't needed to render the page. Putting non-critical scripts in the footer keeps them from blocking the page while it loads.
Follow whatever placement the tool's own instructions specify. Analytics platforms are explicit about which snippet goes where, and getting it backwards is the most common reason verification fails or tracking doesn't fire.
If your theme doesn't have header/footer fields
Options, in order of preference:
- A code-snippet plugin (such as WPCode or Insert Headers and Footers) gives you dedicated header and footer boxes in wp-admin. Paste your script into the header or footer box and save. This survives theme updates because it's stored in the plugin's own settings, not the theme.
- A child theme if you're comfortable editing
header.phpandfooter.phpdirectly and want the change to be part of your theme's code rather than a plugin setting. This is more work to set up but avoids adding another plugin. - Editing the active theme's files directly only as a last resort, and only if you understand the update will erase it. Not recommended.
Whichever route you pick, test on a copy of your site first if the site is a store or otherwise business-critical. Set up WordPress staging, install the plugin or make the edit there, confirm the script fires correctly, then repeat on live. It's a low-risk change, but "low risk" isn't "no risk," especially on a WooCommerce store where a bad edit to footer.php can take the whole site down.
Verifying the tag actually works
Don't assume it's live after pasting. Check:
- View page source (right-click → View Page Source, not just inspect element) and search for a snippet of your tracking ID to confirm it rendered on the actual page, not just in the editor preview.
- Google Search Console verification specifically checks for the meta tag or file at the domain root, so confirm it's present on the homepage before clicking "Verify" in Search Console.
- Analytics real-time reports (Google Analytics has a Realtime view) show whether the tag is actually sending data when you visit the site yourself.
If the tag isn't showing up in page source after you saved it, clear any caching first. Every Flashcloud WordPress install runs LiteSpeed Cache with server-side caching, and a cached page can serve the old header/footer for a while after you make a change. Purge your caching plugin's cache, or wait for it to expire naturally, then check page source again.
A note on backups
Header and footer code is low-risk to add or remove, but if you're installing a new plugin to do it, that's still a change to your site. Your account has automatic daily backups, so you're covered if something goes sideways. See My WordPress site is slow if a new plugin ends up dragging down performance, since every additional plugin is one more thing loading on each page.