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
Write the patchAdd screenshotsEnsure proper test coverage
User interface changes
Anywhere "Container ID" is present, we should also add "GTM Hostname"


API changes
None
Data model changes
All container instances now have a gtm_hostname property
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | support_server_side_gtm-3241123-19.patch | 10.13 KB | roaldnel |
| #3 | Instance Form Screenshot.png | 150.02 KB | WidgetsBurritos |
| #3 | Instance Overview Screenshot.png | 61.14 KB | WidgetsBurritos |
Issue fork google_tag-3241123
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
Comment #3
WidgetsBurritos commentedI've attached screenshots here of the proposed UX changes:
Comment #4
WidgetsBurritos commentedOkay, 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.
Comment #5
donal_obscurity commentedIs there anything I can do to help move this feature forward? I reviewed the code in GitLab and it seems fairly straightforward. LGTM.
Comment #6
hocuComment #7
anybodySuper cool and helpful functionality. Could a maintainer have a look? :)
Comment #9
rpayanmThe last patch did not apply, so I updated it.
Comment #10
trickfun commentedSorry.
how can apply the patch? there is not patch file but only branch.
thank you for your help
Comment #11
rishi.kulshreshtha@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
Comment #12
andeersg commentedCan confirm that this works, patch applied without problems and functionality works.
Comment #13
anybodyThis is a really nice functionality, any maintainer plans to review this?
Comment #14
solotandem commented@Anybody Yes I will.
Thanks to all.
Comment #15
tema commentedHello, are you still working on this? Any plans to port this for 2.x?
Comment #17
solotandem commentedThanks 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.
Comment #19
roaldnel commentedWe 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.