Setting Up A Server-Side GTM Container Using Google Cloud Platform
How long will it take?
We anticipate it should take you 45-60 minutes to complete your Google Cloud Run setup.
10-15 min to set up & share GTM container
0-10 min to set up Google billing account
15-20 min to configure Cloud Run server
It will also take you about 10 minutes more to set make necessary edits to your DNS records.
Total: 35-55 minutes.
Accesses Needed:
Youâll need access to a Google account with admin access. This should be the same account used to set up the client-side GTM, GA4, etc. This is needed in order to set up the below 3 items:
GTM container
Google Billing account
Configure the GTM server in Cloud Run.
To add DNS records, youâll need DNS registrar account access.
Youâll also need access and authority to use a company credit card to set up a Google billing account.
Automatically provisioning a server in Google Cloud Platform (GCP) is comprised of 5 parts.
Part 1: Establish a GTM Container for Server-Side Tracking
Go to tagmanager.google.com, making sure youâre logged into the correct Google account for your organization. Preferably, it should be the same account that owns any other Google products you have set up (other Google Tag Manager accounts, Google Analytics properties, etc).
Find the existing account where your GTM web container exists, and click the ⌠menu button, then click Create Container.
We suggest using the URL of your website to name your container
(For the purposes of this example, we will be using yourcompanydomain.com)
Select Server from the âTarget Platformâ list.
If you donât see an existing account, create a new one by clicking Create Account:
On the Account Setup screen:
We suggest using the format âYour Company â Server-Sideâ) to name your account.
Leave the country as United States
Leave the box for sharing data anonymously unchecked
We suggest using the URL of your website to name your container
(For the purposes of this example, we will be using yourcompanydomain.com)
Select Server from the âTarget Platformâ list.
Click Create and accept the data processing agreement
Your Server-Side Google Tag Manager (âSSGTMâ) container is now created, and you will be sent to the Tag Manager interface. The first thing you see will be a pop-up asking you to set up a tagging server. Select Automatically provision tagging server.
Part 2: Set Up a Tagging Server in Google Cloud Platform
To move forward from here, youâll need a billing account. If you already have one, it may be automatically selected. Once youâve verified it has the correct payment information, select it, click Select billing account and create server, then once your server has been created, proceed to Part 3.
Create a Billing Account
If you need to create a new billing account, do so now. Youâll simply need to agree to the terms, add your payment information, then click Submit (button text may vary). Immediately after creating a billing account, you should be returned to the same screen where you originally clicked Automatically provision tagging server. If everything looks good, click Select billing account and create server, then once your server has been created, proceed to Part 3.
If you don't see the billing account you just created yet, Google may just need a minuteâtry refreshing the page. (Donât click 'Create a billing account' twice)
If you werenât returned to the right screen, hereâs how to navigate back:
From the Tag Manager interface (tagmanager.google.com), find the GTM Container with type âServerâ you just created, and click on it.
You will be sent to the home screen of your SSGTM account. Click on the Admin tab.
Click on Container Settings at the top of the list on the right.
Click on Set up your tagging server
Click Automatically provision tagging server.
Select your billing account from the drop-down, and finally, click Select billing account and create server.
Finally, Google will create your server. (It will likely take a few minutes)
Part 3: Configure and Verify a Custom Domain
Once your server is created, in order to get the maximum benefit of server-side tagging, itâs essential to set up a custom URL for it using your own domain.
Navigate back to Container Settings (in the Admin tab of tagmanager.google.com).
Under the âGoogle Cloud Platform Project IDâ section, click the outbound link icon to go to the Google Cloud Server associated with the Server-Side Tag Manager.
A new tab will open displaying your serverâs dashboard at console.cloud.google.com. Click on the 3 horizontal lines in the top left of the screen and within the Products menu, find and select Cloud Run.
Here, you will see two servers which could be labeled a few different ways. You want to find and click on the live server. (This will be named without a suffix at all, or with a âprodâ or âliveâ suffix. It will not have a âpreviewâ or âdebugâ suffix.) For example:
Once you open the live server instance, click the INTEGRATIONS tab, then click + ADD INTEGRATIONS, then finally click Custom domains - Google Cloud Load Balancing
If you see an error message similar to the one in the screenshot below, click GRANT ALL.
If you see a notification that some APIs must be enabled, click ENABLE.
Under âRoutes,â fill in Domain 1 with the full URL of the subdomain youâd like to use. Leave the âPath 1â and âService 1â fields as they were. Then, click Submit at the very bottom of the page.
In the example below, we have used âgtmssâ as the subdomain but the full URL would be âgtmss.yourcompanydomain.comâ. You could use âssâ, âssgtmâ, or any other subdomain youâd like. This URL will potentially be visible, at least momentarily, to customers in some situations/browsers.
It will take a few minutes to complete the setup.
After a few minutes, you will see the DNS records that you need to add in your websiteâs DNS provider. Theyâll be at the bottom of the âIntegration Detailsâ screen in the âConnect to Custom Domainâ section.
Note: you wonât see âDeployedâ for SSL Certificate until you have completed Part 4 below.
Part 4: Edit Your Websiteâs DNS Records
Now itâs time to create and point the subdomain you just chose (e.g. gtmss.yourcompanydomain.com) to the GTM server youâve created.
You will need to log in to your domain name registrar and create a new DNS record for the subdomain you want to use. Here are the DNS record specifics you would use from the example in the screenshot above. (These items will be different for you!)
Type: A
Host or Name: gtmss
âDATAâ, âIPv4 addressâ, âPoints Toâ, or âValueâ: 34.120.224.52
TTL: Auto or Default (no need to change to 3600 as seen in the screenshot)
Proxy status: Disable (If you donât see Proxy status as an editable field, donât worry. It will be disabled by default.)
It usually takes a few hours, and may take up to 72, to fully set up the custom domain. Once the domain is completely added and verified, youâll see the SSL Certificate field turn âDeployedâ under the Integration Details as seen in the screenshot below.
Important Note:
1. If you have a Content Security Policy (CSP) enabled, you must add the server endpoint (the new subdomain you created) as a trusted source in your CSP. This should be added to both connect-src
and script-src
directives. Otherwise, the browser will block those requests.
Furthermore, the below cases may be relevant, depending on your set-up.
2. Explicitly Define Google Tag Manager in CSP
Include rules for GTMâs client-side scripts in script-src
and ensure that any dynamically loaded resources (e.g., analytics.js or gtag.js) are accounted for.
3. Use Nonce or Hash for Inline Scripts
If your implementation requires inline scripts (e.g., custom JavaScript in GTM), use CSP with nonces or hashes to allow only trusted inline scripts to execute.
Please get in touch with our team if needed! Oftentimes, it can take some time to determine what steps are needed, and some testing may be required. This is normal, and weâre used to it. Weâre happy to troubleshoot any specific cases with you, just let us know!
Part 5: Configure GTM Container + Grant Rain Access
Next, youâll need to configure your new custom domain in the GTM Server container you created during Part 1. Start by navigating to tagmanager.google.com. You may still have that tab open. (Again, please ensure you are logged in and using the correct Google accountâGoogle has a bad habit of randomly switching the account youâre logged into.)
Navigate to your Container Settings (Click your container -> Admin tab -> Container Settings)
Click Add URL, paste in the custom domain you just set up (adding âhttps://â to the beginning), and click Save.
Share Access with RAIN
The below steps will not be necessary if you created your GTM server container in a pre-existing account which we already have admin access to.
Navigate back to your Google Tag Manager account at tagmanager.google.com (again, ensuring you are logged in and using the same Google profile).
Click on your Server-Side Container â Admin â User Management
Click the blue â icon in the top right and select Add Users
Enter âsupport@rainlocal.comâ and âanalytics@rainlocal.comâ into the Email addresses field.
Check the box for Administrator access, then click Invite.
(Alternatively, you may select âUserâ rather than Admin, but in this case, you will need to click Container Permissions and select Publish.)
Youâre done! This completes the server-side Google Tag Manager installation.
Please let us know when youâve finished, so we can confirm everything is looking good from our end.
Thank you!