Problem/Motivation

Google Tag Manager now offers the ability to host your own server-side instances. This helps with some third-party vs first-party cookie concerns.

In its current state, the google_tag module only supports GTM hosted at www.googletagmanager.com.

Proposed resolution

Add a gtm_hostname property to all containers and initialize the default value to www.googletagmanager.com across all container instances to maintain parity with existing functionality.

Remaining tasks

  1. Write the patch
  2. Add screenshots
  3. Ensure proper test coverage

User interface changes

Anywhere "Container ID" is present, we should also add "GTM Hostname"

Instance overview screenshot

Instance form screenshot

API changes

None

Data model changes

All container instances now have a gtm_hostname property

Issue fork google_tag-3241123

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

WidgetsBurritos created an issue. See original summary.

WidgetsBurritos’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new61.14 KB
new150.02 KB

I've attached screenshots here of the proposed UX changes:

Instance overview screenshot

Instance form screenshot

WidgetsBurritos’s picture

Assigned: WidgetsBurritos » Unassigned
Issue summary: View changes

Okay, those last two changes after changing the issue status were because I had missed committed the TestBase file and also removing an unrelated whitespace change that was mistakenly committed the first time around. This is now officially ready for review.

donal_obscurity’s picture

Is there anything I can do to help move this feature forward? I reviewed the code in GitLab and it seems fairly straightforward. LGTM.

hocu’s picture

Status: Needs review » Reviewed & tested by the community
anybody’s picture

Super cool and helpful functionality. Could a maintainer have a look? :)

rpayanm made their first commit to this issue’s fork.

rpayanm’s picture

The last patch did not apply, so I updated it.

trickfun’s picture

Sorry.
how can apply the patch? there is not patch file but only branch.
thank you for your help

rishi.kulshreshtha’s picture

@trickfun, you can use https://git.drupalcode.org/project/google_tag/-/merge_requests/6.diff as the location of the patch in your composer.json

andeersg’s picture

Can confirm that this works, patch applied without problems and functionality works.

anybody’s picture

This is a really nice functionality, any maintainer plans to review this?

solotandem’s picture

@Anybody Yes I will.
Thanks to all.

tema’s picture

Hello, are you still working on this? Any plans to port this for 2.x?

  • solotandem committed eb144b16 on 8.x-1.x
    Issue #3241123 by WidgetsBurritos, solotandem Support a custom tagging...
solotandem’s picture

Status: Reviewed & tested by the community » Fixed

Thanks to everyone with input.

Commit follows the merge request with some minor changes. The primary visual difference is adding the hostname to the advanced tab instead of the general tab.

Status: Fixed » Closed (fixed)

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

roaldnel’s picture

StatusFileSize
new10.13 KB

We have increasingly received requests from clients to add the script in a different format presumably constructed by GTM as such I have further updated the code changes that this issue brought about to apply this new format. The primary change can be found in lines 275 to 306 of the src/Entity/Container.php file. The rest of the changes were mainly cleaning up the code. I have attached a patch with the proposed changes, any input or improvements are welcome.