Add tracking scripts to WordPress that wait for consent
Paste Google Analytics, Meta Pixel or any tracking snippet into Omea Consent › Scripts and it stays blocked until the visitor consents to its category.
On this page
Under the GDPR and the ePrivacy rules, analytics and advertising scripts must not run before the visitor agrees. Omea Consent handles this for any snippet you paste into Scripts: the code is printed inert and only runs once the visitor consents to its category – on the same page, without a reload.
Add a script
- Open Scripts Go to Omea Consent › Scripts and click Add script.
- Name the script Give it a name you will recognise, for example Meta Pixel.
- Choose a category Pick Functional, Statistics or Marketing from Choose a category…. The script only runs after the visitor accepts that category. Choose Necessary only for scripts the site can’t work without – they run for everyone.
- Choose where it loads Set Location to Head, Body or Footer – wherever the vendor’s instructions say.
- Paste the code or the URL Pick Inline code and paste the whole snippet, or External URL and enter the script address (optionally with Async, Defer or custom attributes).
- Save Leave Enabled on and click Save script.
The note under the fields confirms the rule, for example “The script is rendered inert and only runs after the visitor accepts Statistics.”
Which category should a script use?
| Category | Use it for | Google Consent Mode type |
|---|---|---|
| Necessary | Code the site can’t work without. Runs for every visitor. | security_storage |
| Functional | Chat widgets, preference features, embedded tools. | functionality_storage, personalization_storage |
| Statistics | Google Analytics, Matomo, Hotjar, Clarity. | analytics_storage |
| Marketing | Meta Pixel, TikTok Pixel, LinkedIn Insight Tag, Google Ads, remarketing. | ad_storage, ad_user_data, ad_personalization |
Since version 1.0.2 a new script has no default category – you must choose one. Older versions defaulted to Necessary, which meant the script ran for everyone. If you upgraded, check that none of your tracking scripts sit in Necessary. More on categories: Cookie consent categories explained.
What about Google tags?
Google Analytics 4, Google Ads and Google Tag Manager also listen to Google Consent Mode v2, which Omea Consent always sends. If you paste a Google tag into Scripts, give it the category that matches its purpose (Statistics for GA4, Marketing for Google Ads). With Omea Consent Pro you don’t paste anything: you enter the tag ID and the plugin loads it with Consent Mode for you.
What Scripts can’t see
Scripts only controls the code you paste there. Tracking code that your theme or another plugin adds is not held by default. To catch it too, turn on auto-blocking, or remove it from the theme/plugin and paste it into Scripts instead.
Body location: scripts set to Body are printed through the
wp_body_openhook. Most modern themes support it; if a Body script never appears, your theme doesn’t – use Head or Footer instead.
Manage your scripts
The Scripts table lists every snippet with its category, type (Inline or External URL), location and an Enabled switch. Use Edit to change a script and Delete to remove it. Switching a script off keeps it saved but stops it from loading.