
When choosing a deployment method, there are multiple options, each with its benefits and challenges. For example:
- Google Cloud Platform (GCP): Provides flexibility, scalability, and security but requires some technical skills for setup and maintenance.
- Stape: A user-friendly solution with a hassle-free setup, ideal for small to mid-sized businesses. However, it can become costly with high data volumes and has limited flexibility.
- Self-hosted: Offers complete control but demands significant technical resources and ongoing maintenance.
For my sGTM deployments, I prefer Google Cloud Run. It provides auto-scaling, seamless integration with other Google Cloud services, is cost-efficient, and is a recommended method for deploying sGTM.
In this guide, I’ll walk you through the manual deployment of a server-side GTM container on Google Cloud Run in under 30 minutes. As a bonus, I’ve prepared a server GTM boilerplate with preconfigured GA4, Google Ads, and Facebook CAPI tags ready to use.

Prerequisites
Before we begin, make sure you have:
- A set client-side Google Tag Manager (cGTM) container.
- A Google Cloud Platform (GCP) account with enabled billing.
Step-by-Step Deployment
1. Create a Server GTM Container
- Open Google Tag Manager.
- Create Container.
- Select Server as the container type.
- In the Install Google Tag Manager pop-up, choose Manually provision tagging server.
- Keep this window open, as you’ll need the Container Config later.

2. Open Google Cloud Console
- Navigate to Google Cloud Console.
3. Create a New Project
- Click the project selector dropdown and choose New Project.
- Name it (e.g., company-name-marketing-sgtm).
- Click Create and wait for provisioning.
- Select project.
4. Open Cloud Shell
- Go to the Cloud Run. You can use Search(1).
- Click Activate Cloud Shell(2).
- Ensure you’re in the correct project(3).
- If needed, switch projects with ‘gcloud config set project [your-project-id]‘

5. Deploy Server-Side GTM
- Copy and paste the following command into the Cloud Shell and press Enter:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/selnekovic/sgtm-shell-script/main/sgtm_shell.sh)"
- Follow the on-screen instructions to complete the deployment.

- Authorize.
- Enable API’s.
- Choose a region for debugging and production server. I usually use [22] europe-west4 (Netherlands) because of the custom domain mapping.
NOTE: Custom domain mapping is available only in specific regions. Refer to Google’s documentation for details.
To fully maximize the benefits of server-side GTM, map the server to a custom domain.

6. Verify Deployment
- After a successful deployment, refresh your browser to verify that your sGTM server instances are up and running.

7. Configure Server Container URL
- Click on the production server in the Cloud Run.
- Copy the Cloud Run service URL from the console.

- Navigate back to your server GTM container, then go to Admin > Container Settings.
- Paste the copied Cloud Run service URL into the Server Container URL field in your sGTM container settings. Save.

8. Link Client-side GTM to Server-side GTM
- In your client-side GTM container (cGTM), go to Tags.
- Open the Configuration tag.
- Add the server_container_url parameter and paste the copied Cloud Run service URL.

BONUS: Import Server GTM Boilerplate
- Navigate to GitHub.
- Download the server GTM boilerplate from the GitHub repository.

- Navigate back to your server GTM container, then go to Admin > Import Container.
- Import the boilerplate.

- Update the variables labeled **EDIT** with the appropriate values. Insert the Measurement ID and configure the necessary settings for Google Ads and Facebook CAPI.
Congratulations! You’re ready to test — open Preview in your server container.
If you haven’t published the client-side container with the modified Configuration Tag, you have to open your site in Preview mode in the client-side GTM.
Hopefully, everything works. If you run into any issues, feel free to reach out. I’ll be happy to help!