Replacing tag manager code for subdomain by using Wordpress

Hallo,

following your instructions in this article, https://gtm-server.com/how-to-set-up-google-tag-manager-server-side-container/

at point 9 you recommend to modify the Google Tag Manager container code, replacing www.googletagmanager.com with the created subdomain.

My question is: How do I change this Tag Manager code when I am using the Stape Wordpress Plugin to place Tag Manager container?

Hope you can help. Thank you!

Hello,

Wordpress plugin has a box called ‘GTM server container URL’ - put the subdomain there.

1 Like

Hi,

Thank you for your response.
I’v placed the GTM web & our subdomain in de plugin. Which brought me to a few other questions.

  1. When I save it like that I see in the Tag Assistant the GTM Web (not server gtm is that correct?)
  2. I tried to add the custom loader but am I correct if I say I don’t need to add any more settings? Because when I add the Container identifier, the GTM web disappears from my website?
  3. To check if the GA4 was fired correct in the GTMs. But to do this I need the HTTP Header Config and need a URL from the Server preview. However when I click to preview I do not get a preview header value. I tried to set the Server container URLs to my subdomain url. In this case I just get the summery empty. And I tried to use the Server container URLs as https://gt (which was said in: How to set up Google Tag Manager Server Container - Stape number 9). But when I say preview I get a page error check if gt has a typo.

Hope you can help me with these as well.

Kind regards.

  1. You can’t embed a sever container on site, doesn’t work like that. So yes, it should be web

  2. You do need to add a custom loader, the part where GTM disappears - hard to comment, can you share the site in question at least? Need more details

  3. You don’t need Header Config, just launch both web & server preview and everything will flow. Preview URL of the server container should be whichever domain you have added on Stape (or the standard stape one), you also need to make sure that is the domain you are using as transport_url

Hi Dan,

Thank you for the quick response. As for number 2. It’s difficult to show you considering I’m implementing it on the staging website. I can try to specify this by using some screenshots.

On the website we’ve got live https://hide-and-seek.nl/ we only have the GTM web container just implemented a different way. When I look at the Tag Manager Assistant I see the GTM and for example also the Optimize, GA4, Universal and Ads remarketing Tag.

(image at the bottom > right top image)

But when I look at the Staging website where I implemented this (unfortunatelly blocked for outside with a password so I cannot share this site) by using the Stape plugin I only get the GTM, Universal and Ads remarketing tag.

(image at the bottom > left top image)

This is what I’ve placed in the plugin settings.
(image at the bottom > bottom image)

Hope this is enough for the detais.

Kinds regards,

Jamie

So you have GTM present in both examples, what seems to be the problem then?

Thing is you’ve loaded GTM successfully, at which point it doesn’t make any difference where you loaded it from - it’s the same container and it will run tags according to whatever you have set up in it.

If you’re referring to lack of Optimize and gtag - on your production site the former is loaded by inline code, not GTM and the latter is loaded by another container (GTM-5N5F2J2) hence you don’t see those hits on staging.

Hi Dan,

The GTM used to be in the GTM-5N5F2J2. But we paused all the tags in this GTM and uploaded them in the GTM-T8J95W. That is why I would think this should also be on the staging where we only implemented the GTM-T8J95W. For example I see the Analytics config triggered in this GTM container. But not on the website

.

these are screenshots from your live website, like I said, Optimize is loaded outside of GTM, gtag is loaded by GTM-5N5F2J2. You can also see that /collect GA4 hits are initiated by GTM-5N5F2J2

Don’t know what’s going on staging, for the lack of access.

p.s. yes, Google Analytics (Universal) is in GTM-T8J95W:

@Jamie_van_der_Poel

bottom line here is like I said: you load the same container, regardless of where you load it from.

Here’s the standard loader https://www.googletagmanager.com/gtm.js?id=GTM-T8J95W put this into browser and you’ll get a JSON of your container, now replace the domain with whatever custom subdomain you have for this and compare the result - literally the same thing will be returned in response.

Hi Dan,

Thanks. But It’s kinda strange. When I open the console I see the GA4 is connected to the GTM T8J95W

Hi Dan!,

If been testing some things in the meantime on the staging website. But for me it seems like it has something to do with the Stape Plugin (or settings). What I’ve done, I made a new GTM and placed this by just using a GTM plugin (only gtm no server gtm) on the website with only the GA4 configuration. This worked I saw the GTM and de GA4 (in Tag assistant and in the Console).

When I pace this same GTM in the wordpress plugin settings in Stape I notice, it takes a long time to load the GTM, and the GA4 never loads.

Please help, where could this go wrong?

Kind regards,

Jamie

@Jamie_van_der_Poel I need actual examples, either access or network hits screenshots to even start assessing this.

Hi Dan,

I let it rest for a day a when I look in the console now I see this. So it looks like the GA4 is on the website and uses the GTM (I do also see something with the server side url we used in Stape.).

We also set in the Stape.oi power-up on so what I only was wondering is it correct we see or Server Side url in the console. Shouldn’t it bee something with gtm.js? Like we see in the manual Modify request path with web GTM and GA4 - Stape step 4?

Kind regards,

Jamie