Problem/Motivation

The module dows not provide the ability to include a GTM environment query parameters to the GTM script URL

Proposed resolution

Add ability to include GTM Environment ID and Token in configuration and include in the rendered snippets.

Comments

matteo.borgognoni created an issue. See original summary.

matteo.borgognoni’s picture

StatusFileSize
new4.19 KB
matteo.borgognoni’s picture

batigolix’s picture

I found some issues with the patch:

+function cookiebot_gtm_prepare_query() {

This is missing a documentation block.

Also , as it is a helper function, I think it is a convention to rename it to _cookiebot_gtm_prepare_query()

+  // Prepare extra query parameters for the GTM script URL.
+  $query = '"' . cookiebot_gtm_prepare_query() . '"';

Concatenating a function with some strings looks weird. I'd do something like:

$query = cookiebot_gtm_prepare_query();
$query = '"' . $query . '"';

But maybe there is a more elegant solution for this.

batigolix’s picture

Status: Active » Needs work
batigolix’s picture

Issue tags: +finalist-sprint
ashley george’s picture

StatusFileSize
new4.88 KB

I was finding that the with Matteo's patch the ampersands in the GTM script were being rendered as encoded (&).

I notice that when the html_tag was being rendered, it was being run through a sanitising function before setting that new value as the eventual markup.

In our module, if you set the #value of the html_tag as markup then it bypasses the sanitisation.

I'm not sure if this is the right thing to do but it allowed us to move forward.

ashley george’s picture

I realise I accidentally included a change from a seperate patch which altered the script to use 'defer' rather that 'async'. Here's an update without that.

ashley george’s picture

StatusFileSize
new4.89 KB

I realised I needed to do something similar to the noscript output of this module.

roaldnel’s picture

Version: 1.0.x-dev » 1.0.14
Status: Needs work » Fixed

I have tested the latest patch and I also applied changes as suggested by batigolix. The code was released in version 1.0.14.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.