With Google Tag Manager consent mode v2, ajax view is empty after using facets

Created on 19 July 2024, 7 months ago

Problem/Motivation

Google Tag Manager Consent Mode v2 is adding query parameters under certain conditions to ensure (force) user tracking.
In the context of a view using ajax with facets, after using one facet the view is empty, without errors in the browser nor in the Drupal log nor in the webserver PHP error log.

Debugging lead me to the PrettyPathsActiveFilters class where Url::fromUserInput($q) is receiving an URL that includes the hostname causing an exception (I only see it with xdebug).

Steps to reproduce

Drupal 10.1.8
Facets 2.0.6
Facets Pretty Paths 2.0.1

A view with ajax activated + facets configured to filter the view + facets pretty paths activated as URL processor of the facet source.

Then you need a GTM container on your site with consent mode v2 activated, a consent banner (I used a free version of Axeptio). This configured you need to refuse the consent, then you see a _gl query parameter added tu the URL during navigation.
At this point you should see nothing in your view with facets after some clics on facets.

Proposed resolution

I haven't found the reason why the hostname is included in this case so I will follow up with a fix proposal where a check is added to remove the hostname if present in the query.

Remaining tasks

Merge this fix if we can't find a better solution (could we act where the hostname is added?)

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇫🇷France cedric_a France

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024