Staging Guard: your test copy, out of Google and out of your analytics
A staging copy brings everything from the live site: the Google Tag Manager container, GA4, Google Ads conversions, the Meta pixel and WooCommerce webhooks. Staging Guard switches them off on the copy without changing any setting, so you can push it back to production as it is.
- Price
- Free, GPLv2 or later
- Requirements
- WordPress 5.7 or later and PHP 7.2 or later
- Settings
- Under Tools → Staging Guard
- Data
- No external requests and no visitor data
Why it exists
GA4 does not filter by domain by default, and Google Tag Manager fires on staging.client.com just as it does on client.com. We saw it on the staging copy of a site we maintain: test visits and test orders ended up in the client's real reports, audiences and conversions.
Turning off the analytics plugins on the copy does not work: when the database goes back to production, those changes go with it. Staging Guard does everything with filters at run time and saves nothing in other plugins' settings.
How to use it
- Install and activate the plugin on the staging copy.
- Go to Tools → Staging Guard: it tells you whether it is acting and why.
- Optionally, tick "Stop outgoing email" or enter an address to receive every email from the copy there.
- Clear the page cache so the noindex and the blocking also reach cached pages.
In review for the WordPress.org plugin directory. In the meantime, download it from GitHub.
What it does
- Out of Google. noindex on every page, with Yoast, Rank Math or SEOPress too, and an X-Robots-Tag header on every PHP response. robots.txt stays open on purpose, so Google can see the noindex.
- No real analytics. It stops PixelYourSite, GTM4WP, Site Kit, MonsterInsights and Elementor Pro custom code. As a safety net, it removes any GTM, Google Analytics, Google Ads, Meta, Clarity, Hotjar, LinkedIn, TikTok or Bing tag left in the HTML.
- Webhooks and pings paused. Test orders do not reach your ERP, CRM, shipping or invoicing service, and new posts do not notify anyone.
- Email, only if you ask. It is off by default, because you often need to test forms. One checkbox drops everything, or sends it to a single address with the original recipient in the subject. It keeps the last 20.
- A checkbox for each thing. Everything is on except email, and you can turn off whatever you need to test.
- It does not act on a live site. It only works when the domain looks like a test copy (staging., dev., test., .local, hosts' staging domains), when WP_ENVIRONMENT_TYPE is not production or when "Discourage search engines" is checked. If it reaches the live site, it does nothing and warns you.
How to check it works
- curl -sI on the staging home page must return the X-Robots-Tag: noindex, nofollow header.
- The HTML has a comment <!-- agencia-rse-staging-guard 1.0.0: staging, N tracking tags removed -->.
- In the browser, after accepting cookies and clicking around (WP Rocket delays scripts until the first interaction), the Network tab must show no requests to googletagmanager, google-analytics, facebook or doubleclick.
- The AGRSE_STAGING constant (true or false) in wp-config.php forces the plugin on or off.
We use it on the staging copies of the sites we maintain and publish it for free for anyone who needs it. See custom WordPress plugins
Frequently asked questions
What happens if I push staging to production with the plugin active?
In automatic mode it sees a live domain and does nothing, and the dashboard shows a warning so you can deactivate it. "Always on" is tied to the staging domain, so it does not travel with the database either.
Does it change anything in my analytics or SEO plugins?
No. It saves nothing in their settings: it works with filters while it is active. When you deactivate it or go back to production, everything is as it was.
Does it block email sent by SMTP plugins?
It uses the WordPress pre_wp_mail filter, which WP Mail SMTP and any plugin that sends through wp_mail() respect. If an SMTP plugin replaces that function with its own, use that plugin's option to turn sending off.
What if I want to test analytics on staging?
Untick "Block analytics and ad tags". The noindex stays on.
Need a plugin made for your site?
We build custom WordPress and WooCommerce plugins: your business logic, editors for your team and integrations. Your code, fixed quote.
Your first consultation is free. We look at what you tell us and reply within 48 business hours.