SiteHost provides a standard GTM Web Image, built and maintained by SiteHost from Google's official server-side Google Tag Manager (sGTM) image. This means you can deploy a working sGTM server directly from the Control Panel, without creating or maintaining a custom image yourself.
This article covers provisioning two containers from this image, a preview server and a tagging server, which together make up a working sGTM deployment.
The overall process is:
NOTE: SiteHost maintains the image itself. The only configuration required on your side is environment variables. A MySQL/database container is not required.
Before provisioning anything in SiteHost, you need a Server container in Google Tag Manager. This is what generates the Container Config string used in Step 3, and it's the destination the tagging server reports back to.
NOTE: These articles use Google's own Cloud Run automatic provisioning as their example deployment. Only the server container creation and GA4 client/tag/web-container configuration portions apply to this deployment. the actual server hosting is done through SiteHost, as described below, not Cloud Run.
You will repeat this process twice, once for the preview server, once for the tagging server. Both are created the same way; only the environment variables differ (see Step 3).
Before creating the containers, get your Container Config string ready, since it's needed for both:
Page 1:
sgtm-preview.example.com for the preview container, sgtm.example.com for the tagging container). A domain or subdomain is required at this step.Page 2:
Repeat both pages for the second container.
You'll now have two containers, for example:
sgtm-preview.example.com, the preview serversgtm.example.com, the tagging serverUse the Container Config string retrieved in Step 2 for both containers below.
Preview container:
| Variable | Value |
|---|---|
CONTAINER_CONFIG |
Your Container Config string |
RUN_AS_PREVIEW_SERVER |
true |
Tagging container:
| Variable | Value |
|---|---|
CONTAINER_CONFIG |
Same Container Config string |
PREVIEW_SERVER_URL |
The preview container's URL, e.g. https://sgtm-preview.example.com |
If any of these are left blank or incorrect, the container will fail to start, this is not optional configuration, unlike a typical web container where environment variables might just customize behavior.
If you need to change environment variables after deployment, this can be done from the container's page in the Control Panel, restart the container afterward for the change to take effect.
Optionally, if you are using BiqQuery or Firestore, you can define the GOOGLE_APPLICATION_CREDENTIALS and GOOGLE_CLOUD_PROJECT environmental variables.
The GOOGLE_APPLICATION_CREDENTIALS environment variable is expected to be a JSON file like: /container/config/service_account_key.json. Google has an article with more information here: (Optional) Include Google Cloud credentials
This would require adding an SSH user linked to both the preview and tagging containers, and adding the /container/config/service_account_key.json file over SSH/SFTP.
Both containers need a valid SSL certificate before they can be used, since Google Tag Manager's preview flow and the tagging server both expect HTTPS.
sgtm.example.com) points to the Cloud Container's server IP address. The certificate request will fail if the DNS record isn't in place yet.This can be done any time after the containers are deployed, it doesn't need to happen before Step 2 or 3, but both containers must have SSL enabled before testing (Step 5) or connecting to Google Tag Manager (Step 6), since both of those steps require HTTPS URLs.
Since environment variables are already set during creation (Step 3), both containers should start correctly on first deploy. Confirm this:
Each container exposes a health check endpoint. Visit or curl:
https://sgtm-preview.example.com/healthy
https://sgtm.example.com/healthy
Both should return ok.
https://sgtm.example.com.If events show up correctly in Preview, the deployment is complete and working end to end.