# Deploying Server-Side Google Tag Manager on Cloud Run

DevFeed: [Deploying Server-Side Google Tag Manager on Cloud Run](<https://devfeed.tech/articles/deploying-server-side-google-tag-manager-on-cloud-run-15600.md>)

Original publisher: [Read original article](<https://developer.squareup.com/blog/deploying-server-side-google-tag-manager-on-cloud-run>)

Author: Amogh Kambale

Published: 2021-07-15T21:00:00Z

Content type: tutorial

Language: en

Sources: [Square Corner](<https://devfeed.tech/sources/square-corner-blog-medium.md>)

Topics: [Cloud Run](<https://devfeed.tech/topics/cloud-run.md>), [Cloud Architecture](<https://devfeed.tech/topics/cloud-architecture.md>), [Google Cloud Platform (GCP)](<https://devfeed.tech/topics/google-cloud.md>), [container](<https://devfeed.tech/topics/container.md>), [CI/CD](<https://devfeed.tech/topics/cicd.md>), [Back end](<https://devfeed.tech/topics/backend.md>), [hosting](<https://devfeed.tech/topics/hosting.md>), [paas and iaas](<https://devfeed.tech/topics/paas-and-iaas.md>)

Tags: [2020](<https://devfeed.tech/tags/2020.md>), [api](<https://devfeed.tech/tags/api.md>), [application](<https://devfeed.tech/tags/application.md>), [applications](<https://devfeed.tech/tags/applications.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [authentication](<https://devfeed.tech/tags/authentication.md>), [automated](<https://devfeed.tech/tags/automated.md>), [automated-deployment](<https://devfeed.tech/tags/automated-deployment.md>), [autoscaling](<https://devfeed.tech/tags/autoscaling.md>), [backend](<https://devfeed.tech/tags/backend.md>), [browser](<https://devfeed.tech/tags/browser.md>), [cloud](<https://devfeed.tech/tags/cloud.md>), [cloud-costs](<https://devfeed.tech/tags/cloud-costs.md>), [cloud-run](<https://devfeed.tech/tags/cloud-run.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [event](<https://devfeed.tech/tags/event.md>), [google](<https://devfeed.tech/tags/google.md>), [google-tag-manager](<https://devfeed.tech/tags/google-tag-manager.md>), [marketing](<https://devfeed.tech/tags/marketing.md>), [processing](<https://devfeed.tech/tags/processing.md>), [server](<https://devfeed.tech/tags/server.md>)

## AI overview

Square chose Cloud Run to host server-side Google Tag Manager because project restrictions ruled out App Engine Flexible, while Kubernetes offered more operational complexity than needed. The setup uses two Cloud Run services built from the same image: Tagging handles requests and proxies preview requests to Preview, which serves the preview UI and is capped at one instance. Environment variables distinguish the roles. Square automates development, staging, and production deployments with Terraform, including environment-specific resource settings. The walkthrough provisions Preview first, then Tagging with Preview's URL, permits unauthenticated traffic, checks each service at `/healthy`, and adds the Tagging URL in Tag Manager. Tagging memory and autoscaling are configurable tradeoffs between performance, cold-start latency, and cloud cost; the article's example uses 512 MiB for production Tagging and 256 MiB elsewhere.

## Source excerpt

Moving marketing event processing out of the browser and into the backend