Set WordPress Tracking Tags
wordpress_set_trackingSet a WordPress site's Google Tag Manager or GA4 measurement id, add code to the site header, or switch off an old tracking snippet.
gtm_id goes into the GTM4WP plugin when that plugin is active, otherwise the connector emits the tag itself, so this works with or without a tag plugin.
remove_id takes a measurement id like "GTM-5H2L5V63" or "AW-851563016" and removes it wherever
it lives — a plugin setting, a header/footer box, or a WPCode snippet (that one is switched
off, not deleted). This is how you stop a site double-counting after a container change. If the
id is hard-coded in a theme PHP file it is reported back under skipped with the file and line;
that copy can now be removed with wordpress_theme_file(mode="remove_block", contains=""),
which backs the file up and reverts automatically if the edit breaks PHP.
head_code="" clears the header code the connector emits.
To change a few words inside the connector's existing header/footer code (an address in a JSON-LD block, a phone number) without resending the whole block, pass replace=[{"find":"old text","with":"new text"}] and replace_in="head" (default) or "body". The current code is read from the site, each find must match exactly (case-sensitive), and confirm=false PREVIEWS how many times each one matches and writes NOTHING; confirm=true applies and re-reads the code to verify. A find whose replacement is already in place is reported as already_applied and skipped, so repeating the call is safe.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ga4_id | No | ||
| gtm_id | No | ||
| confirm | No | ||
| replace | No | ||
| site_url | No | ||
| body_code | No | ||
| head_code | No | ||
| remove_id | No | ||
| replace_in | No | head | |
| enable_snippet | No | ||
| disable_snippet | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||