Skip to main content
Cookbook Maintenance SureCookie

Block a Tracking Script Until Visitors Consent with SureCookie and AI

One script held back until visitors agree, with a rule for its exact domain, checked on the live page.

Difficulty Intermediate
Time ~10 min

Prerequisites

A site connected to WPVibe running SureCookie 1.9 or newer (tested on 1.9.0, free) on WordPress 6.9 or newer, with an administrator account and SureCookie's Enable MCP switch on (SureCookie, Settings, Tools, MCP).

The prompt
My WordPress site uses SureCookie. Hold back [the script, for example the chat widget or the pixel I added by hand] until visitors agree to cookies. WPVibe does not ask for approval before any SureCookie ability runs, so ask me before every change.

1. Run discover_abilities with category surecookie. If its abilities are not there, stop and tell me to install or update the free SureCookie plugin (1.9 or newer, on WordPress 6.9 or newer), then turn on its AI access: in SureCookie's Settings, open Tools, then MCP, switch on Enable MCP and save. SureCookie hides its abilities until that switch is on.
2. Run surecookie/script-blocking with action list_rules. If blocking_active is false, tell me nothing is held back until SureCookie's banner and script blocking are both on, and stop.
3. Run get_page_html on [a page where the script loads] and find its script tag. Note the full domain it loads from, and any inline script next to it that sets it up. If you can't find it, ask me for the script's address and stop. If the tag already has type text/plain and a data-surecookie-category, tell me SureCookie already holds it back under that category. If that category is uncategorized, suggest a real one and, on my yes, run surecookie/script-blocking with action recategorize_resource (type script, the domain, the category). Then stop. If the domain is my own site's domain or a shared code host (such as cdnjs, jsdelivr or unpkg), tell me a rule for it would hold back every other script from there too, that this recipe covers only scripts loaded from the service's own domain, and stop.
4. Run surecookie/script-blocking with action list_resources and search set to that domain. If it is listed with gcm_managed true, tell me Google Consent Mode lets Google's tags load before consent with storage denied, so a rule won't hold it back; whether to keep Consent Mode on is my call. Stop. If it is listed with enforced false, tell me its unenforced_reason and stop. If a rule from step 2 has a value that is part of the script's address, run surecookie/script-blocking with action list_gcm_whitelist: if Consent Mode is on and the address matches one of its patterns, tell me Consent Mode lets it through and stop. Otherwise tell me the rule should hold it back but the page still loads it, ask me to clear my page cache and tell you what I see, and stop. If it is listed with excluded true, tell me it was excluded from blocking and ask whether to hold it back again. On my yes, run surecookie/script-blocking with action include_resource (type and domain) and go to step 7. If it is listed with excluded false, tell me SureCookie lists it although the page shows it loading, and go on.
5. Run surecookie/cookie-categories with action list. Suggest a category (functional for chat, maps, video and booking; analytics for statistics and heatmaps; marketing for ads and pixels) and the full domain as the pattern, never a single word or a bare top-level name: a pattern matches every script whose address contains it. If there is an inline setup script, suggest as a keyword the full name of the object it creates, never a common word such as chat or init: a keyword holds back every inline script on the site that contains it. Show me the rule and wait for my yes.
6. Run surecookie/script-blocking with action create_rule, with value DOMAIN, category CATEGORY_ID, name [a short label], and keywords if I agreed to one. If it refuses the pattern, tell me why and stop.
7. Run get_page_html on the same page again. Confirm the script tag now has type text/plain and data-surecookie-category, and so does the inline setup script if you added a keyword. If it still loads normally, run surecookie/script-blocking with action list_gcm_whitelist: if Consent Mode is on and the address matches one of its patterns, tell me Consent Mode lets it through and stop. Otherwise tell me to clear my page cache and ask you to check again.
8. Tell me the script now loads only after a visitor accepts that category. Tell me how to undo it: ask you to run surecookie/script-blocking with action delete_rule and value DOMAIN, or, if you used include_resource, action exclude_resource with type script and domain DOMAIN.
Already connected?

Skip pasting the full prompt. Drop this into your AI on a site that already has WPVibe:

Run the “Block a Tracking Script Until Visitors Consent with SureCookie and AI” recipe from the WPVibe cookbook on my connected site.

You pasted in a chat widget, a pixel or a heatmap tag, and it loads the moment anyone opens the page. SureCookie holds back scripts from the services in its built-in catalog, scripts its scan has seen and scripts a rule names. A script from anywhere else slips past the banner.

The AI finds where the script loads from, checks on your page whether SureCookie already holds it back, and suggests a category and a blocking rule for its domain. After your yes it adds the rule, then reads your page as a visitor sees it to confirm the script now waits for consent, along with its setup line if you chose to hold that back too.

Rules match any script whose address contains the pattern, so the AI uses the service’s full domain, never a single word, and never your own domain or a shared code host, which would hold back far more than one script. If your site caches pages, clear the cache before checking. To undo it, ask the AI to delete the rule. For a full check of what loads before consent, use this recipe.

Outcome

The script loads only after a visitor accepts its category, confirmed on the page, and you know how to undo it.