How to upgrade your GTM container when you use a Regex Lookup Variable for your Measurement ID

If your Google Tag Manager container uses a Regex Lookup variable for your GA4 Measurement ID, the new container upgrade won't work. You may see GA4 greyed out stating ‘Ineligible for optimization’ and ‘This tag cannot be optimized because it uses a variable in the ID field’.

This applies to any variable in the Tag ID field, including a Lookup Table or even a Constant.

GTM showing GA4 tag ineligible for optimisation because it uses a variable in the ID field

Why the Regex Lookup Gets in the Way

The optimisation flow links your container to each Google destination by its Measurement ID. When the ID is a variable such as {{Regex Lookup - GA4 Measurement ID}}, GTM can't tell which GA4 property the tag belongs to, so it can't consolidate it.

Updating your GA4 Configuration tag with the static ID for the upgrade solves that. Once the new Google Analytics destination tag is published you can then swap the original lookup variable back.

Seven steps to upgrade a GTM container with a static ID, then three steps to switch back to the Regex Lookup for the GA4 Measurement ID

Step by Step

Part 1: Upgrade & Publish with a static ID

  1. Export your container first (Admin → Export Container) so you have a backup.

  2. Swap in the static ID. Open your GA4 Configuration tag and replace {{Regex Lookup - GA4 Measurement ID}} with your production ID, for example G-XXXXXXXXXX. Save the tag.

  3. Start the upgrade. On the Overview page, click Review details in the optimisation banner. If your Google tags have conflicting settings, you'll see Get started instead, and GTM will ask you to choose which settings to keep.

  4. Preview the changes. Click Preview changes to see exactly what will be added and removed.

  5. Add to workspace. Click Add to workspace. Your Google tag is replaced with a Google Analytics destination tag that holds the static ID.

  6. Test in Preview mode. Check that page views and your key events reach the production property.

  7. Publish. Click Submit and name the version, for example "GTM optimisation upgrade (static ID)".

Part 2: Switch back to the Regex Lookup

  1. Edit the destination tag. Open the new Google Analytics destination tag and replace the static ID with your original variable e.g. {{Regex Lookup - GA4 Measurement ID}}. Save.

  2. Test each hostname. In Preview mode, load your production site, then your staging site or other domains, and check each one sends data to the right property.

  3. Republish. Click Submit and name the version, for example "Restore Regex Lookup Measurement ID".

After You Republish

  • Realtime reports: check each GA4 property is receiving traffic from the right hostname.

  • Key events: confirm they're still being recorded in each property over the next few days.

FAQs

Need a Hand?

If your container uses lookup tables, multiple Google tags or cross-domain tracking, Trackify can run the upgrade for you and test it across all your properties. Get in touch.

Comment