GoogleTagUpgradeManager not mapping negate values correctly

Created on 23 August 2023, about 1 year ago
Updated 15 February 2024, 9 months ago

Problem/Motivation

We noticed after upgrading several sites from 8.x-1.x to 2.0.x that the user role condition settings for existing Google Tag containers had been effectively reversed. Containers that were previously configured to only include GTM for the anonymous user role were changed to exclude only the anonymous user role after upgrading to 2.0.x and applying DB updates.

This seems to be tied to the way that the 8.x-1.x config settings are mapped to 2.0.x config settings in the GoogleTagUpgradeManager class used by google_tag_update_8201().

The GoogleTagUpgradeManager::convertConditions() method currently maps any 8.x-1.x xxxx_toggle config setting values to 2.0.x negate values as TRUE because the string value of the $negate_toggle variable used to compare to 8.x-1.x values against ('exclude_listed') does not match the value of GOOGLE_TAG_EXCLUDE_LISTED constant in 8.x-1.x ('exclude listed'). See https://git.drupalcode.org/project/google_tag/-/blob/8.x-1.x/google_tag....

Furthermore, enabling one of the "negate" toggles in 2.0.x is functionally equivalent to setting the 8.x-1.x toggles to 'exclude listed' yet the GoogleTagUpgradeManager::convertConditions() method is currently setting the migrated negate values to TRUE when the 8.x-1.x settings do not match the value of GOOGLE_TAG_EXCLUDE_LISTED and it should actually be doing the opposite. It should be setting the values to TRUE only if they do match the 8.x-1.x 'exclude listed' value.

Steps to reproduce

  • Add a Google Tag container to site using Google Tag 8.x-1.x
  • Configure conditions for container as desired
  • Upgrade Google Tag module to 2.0.x
  • Apply DB updates
  • Notice condition negate checkboxes are all enabled regardless of what the 8.x-1.x corresponding xxxx_toggle configuration settings were

Proposed resolution

Update GoogleTagUpgradeManager::convertConditions() method to map negate values correctly:

  • xxxx_toggle: 'exclude listed' should be mapped to negate: true
  • Other xxxx_toggle values should be mapped to negate: false

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States joegraduate Arizona, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024