Add Your Google Tag Manager Container to WordPress with GTM4WP and AI
Your GTM container ID checked, saved in GTM4WP after your yes, and confirmed on your live home page.
Prerequisites
A site connected to WPVibe running GTM4WP (Google Tag Manager for WordPress) 2.1 or newer (tested on 2.1.1, free) on WordPress 6.9 or newer (tested on 7.1.4), with an administrator account. Your Google Tag Manager container ID (GTM- followed by letters and digits).
My WordPress site uses GTM4WP (Google Tag Manager for WordPress). Add my Google Tag Manager container: [your container ID, for example GTM-ABC1234]. 1. Run discover_abilities with category gtm4wp. If no gtm4wp ability is there, stop and tell me to install or update the free GTM4WP plugin (Google Tag Manager for WordPress, 2.1 or newer, on WordPress 6.9 or newer), or that the site may have switched GTM4WP's abilities off. If the others are there but gtm4wp/update-settings is not, tell me this site keeps GTM4WP's abilities read-only, so the change is made on the GTM4WP settings screen, and stop. 2. My ID must be GTM- followed by capital letters and digits: write it in capitals. If it starts with G- or UA-, it is a Google Analytics ID, not a container: tell me the container ID is at the top of my Tag Manager workspace, next to the container name, and stop. 3. Run gtm4wp/get-status. If hardcoded active is true and locked_rows is true or locked_columns includes id, tell me the containers are set in wp-config.php and must be changed there, and stop. 4. Run gtm4wp/get-settings with keys gtm-containers, gtm-code-placement and gtm-no-gtm-for-logged-in and include_schema true, and keep its values_hash. If a row of gtm-containers already has my ID, tell me it is already set and go to step 7. If there are other rows, show them to me and ask whether to add mine alongside them (both load on every page) or replace them. If I choose replace, tell me every tag in the removed containers stops for every visitor, and ask me again. 5. Look at gtm-code-placement. If it is 0 (footer), tell me it works with every theme but Google Search Console cannot verify the site through Tag Manager with it, and ask whether to switch to 2 (right after the opening body tag, which needs a theme that supports wp_body_open). If it is 3, tell me the container code is switched off and only the data layer is written, and ask whether to switch to 0 or 2. Leave 1 or 2 as it is. 6. Run gtm4wp/export-settings and keep its answer as the backup of my settings: to undo, send the old values from it with gtm4wp/update-settings after the same confirmation, never with import-settings, which replaces every setting. Show me each option you will change with its current value and its new value, and ask: Confirm this change? Wait for my yes. Then run gtm4wp/update-settings with only those options under values, and expected_hash set to the values_hash from get-settings. If it says the settings changed in between, read them again and ask me again. If it says changing settings through the Abilities API is switched off, tell me to change it on the GTM4WP settings screen and stop. If it lists an option under errors, tell me its message: that option was not saved. GTM4WP saves gtm-containers as a whole list: send every row I keep, each with every column exactly as get-settings returned it, plus a new row with id set to my ID and gtm_auth, gtm_preview, domain, path and no_id empty. Send gtm-code-placement only if I chose to change it. 7. Run gtm4wp/get-status and confirm my ID is under containers and no problem asks for a GTM ID. Then run get_page_html for my home page and look for my ID (the answer can be cut short: read on with offset until you find it or reach the end). With placement 1 or 2, also look in the page for googletagmanager.com/ns.html?id= followed by my ID (read on with offset to the end if needed): with placement 2, if the head part is there and that part is not, my theme does not support wp_body_open, so offer to set placement to 0 (footer), and if I say yes, change it the way step 6 does, with the values_hash update-settings just returned; with placement 1, tell me the theme is missing GTM4WP's line of code. If my ID is not on the page at all, look at container_code_output in get-status: false means the placement is off or the container is switched off for this environment. If it is true, tell me a page cache may be serving an older copy and to clear it, or code on the site may switch the container off with GTM4WP's gtm4wp_output_container filter. 8. Tell me what changed. Remind me the container now loads for every visitor, so its latest version should be published in Tag Manager, and that Tag Manager's Preview mode is how to check its tags fire. If gtm-no-gtm-for-logged-in lists my role, tell me the container does not load for me while I am logged in.
Skip pasting the full prompt. Drop this into your AI on a site that already has WPVibe:
Run the “Add Your Google Tag Manager Container to WordPress with GTM4WP and AI” recipe from the WPVibe cookbook on my connected site.
You have a Google Tag Manager container ID, and the guides say to paste two snippets into your theme: one in the head, one right after the body tag. Edit the wrong file and the site breaks, or the next theme update wipes it out. GTM4WP does it without touching the theme, but its settings screen is long.
The AI checks your ID is a container ID and not a Google Analytics one, shows you any containers already set, and asks before it adds yours alongside them or replaces them. It saves the change only after your yes, then checks your home page as a visitor gets it and confirms the container is there, in the right place.
The container loads for every visitor once it is saved, so publish it in Tag Manager first. GTM4WP saves the container list as a whole: the prompt sends back every container you keep, so none is dropped by accident. If you excluded your own role from tracking, you won’t see the container while logged in. To check the whole setup afterwards, use this recipe; to add a tracking snippet without Tag Manager, use this one.
Outcome
Your Tag Manager container loads on every page of your site, checked on the page a visitor gets.