This guide explains how to:
- Manually provision a tagging server on Google Cloud Platform App Engine.
- Upgrade the automatically provisioned tagging server so that it is ready to handle live traffic.
- Increase or decrease the number of servers that are running your server container.
- Keep your tagging server version updated after provisioning the server.
The process involves:
- Creating a Google Cloud Platform Project or navigating to an existing project in Google Cloud Console.
- Running a shell script that will walk you through the steps to setup your tagging server or change the configuration of an existing tagging server.
The testing configuration (set by default during the automatic provisioning process) is appropriate for a small amount of test traffic and for using the Preview feature in Tag Manager. However, we recommend using the shell script to upgrade your server to a production configuration before sending significant live traffic to the server.
In testing configuration, you will not incur any costs in most cases. The testing configuration is an App Engine F1 instance class in the Standard environment.
In production configuration, each server costs approximately $40 / month (USD). Each server is an App Engine instance with 1 vCPU, 0.5 GB memory, 10 GB disk in the Flexible environment. We recommend running a minimum of 3 servers to reduce the risk of data loss in case of a server outage. However, you may choose to run fewer (or more) servers. We expect that autoscaling 3-6 servers (the default) will handle 50-200 requests per second, though the performance will vary with the number of tags, and what those tags do.
See Managing App Engine costs to understand App Engine billing and how to configure billing alerts. We strongly recommend setting up a billing alert.
Create a Google Cloud Platform (GCP) project
If you created a tagging server through the automatic provisioning process, a
GCP project will already exist. You can access it by navigating to
console.cloud.google.com and viewing the
projects you have access to. The project ID will be your container ID suffixed
with a sequence of random characters.
If you did not create a tagging server through the automatic provisioning process:
For new GCP users: Create a new GCP account and create a GCP billing account.
For existing GCP users: Create a new project in GCP. You can name your project whatever you would like, but we recommend using your container ID for convenience. This name is used only within GCP. Please note your Project ID.
Create a tagging server or reconfigure an existing tagging server
- Open the Google Cloud Platform Cloud Shell
Set the Cloud Platform project in the cloud shell. Replace
<PROJECT_ID>with the GCP project ID that you noted earlier:
gcloud config set project <PROJECT_ID>
Run the following command and follow the instructions given by the script.
bash -c "$(curl -fsSL https://googletagmanager.com/static/serverjs/setup.sh)"
This shell script will let you perform any of the following tasks:
- If you have not set up a tagging server yet, this script will help you set it up.
- If you want to start serving production traffic from an existing tagging server, this script will help you add additional servers.
- If you have an existing tagging server, this script will help you change the configuration.
Configure the server container URL
If you previously set up your server using the automatic provisioning process, then skip this step.
Your application will be deployed to an App Engine subdomain. You can run the following command to get the URL:
gcloud app browse
Copy that URL and navigate to your server-side Tag Manager container under Admin > Container Settings. Add that URL under Server container URLs, click Save and navigate back to your workspace.
In Tag Manager, preview the container. If the preview page loads, then everything is set up correctly.
If you have mapped multiple subdomains to a single tagging server and you want
to preview on each subdomain, add additional Server container URLs under
Admin > Container Settings. If multiple URLs are provided, all URL paths
must match (the string of information that comes after the domain name). For
example, you can preview on
example2.com/abc but you
cannot preview on
example2.com/def. If multiple URLs are
added, you will see an icon next to the Preview button that allows you to
select the URL to preview on.
Map custom domain
If you just created a new tagging server, then follow these instructions to point your website subdomain to the tagging server.
Disable App Engine request logging (optional)
By default, App Engine logs information about every single request (e.g. request path, query parameters, etc) that it receives. If your tagging server handles a lot of requests per month (e.g. greater than 1 million), those log messages may incur significant logging charges. To reduce or eliminate the logging charges, we recommend disabling the App Engine request logging. To disable App Engine request logging, follow these steps:
- Navigate to the Logging ->
Logs Router. Make sure
you're in the project that matches your container ID:
- For the Type: Cloud Logging bucket, Name: _Default line, select the overflow menu, then click Edit Sink
- Under Sink destination, select logs bucket _Default
- Under Choose logs to include in sink, add this text to the existing
inclusion filter on a new line:
NOT LOG_ID("appengine.googleapis.com/nginx.request") AND NOT LOG_ID("appengine.googleapis.com/request_log")
- To also disable logging from the load balancer, add this text, on a new
line, to the existing inclusion filter:
NOT LOG_ID("requests"). Note: This will disable all logging from the load balancer, including requests that are not sent to the server container.
- Click Update Sink button at the bottom
Now the App Engine request will be excluded from logging. Check the Logging -> Logs Explorer to ensure that new requests are not appearing in the logs.
Troubleshoot production deployment timeouts
When you run the setup script to create or reconfigure the tagging server, the script may time out. There are several reasons this could happen. The two most common are:
Service accounts have incorrect permissions - The Compute Engine and App Engine service accounts are responsible for deploying and maintaining the production deployment. By default, they are preconfigured with the appropriate permissions. However, in some cases, an organization's policy may cause them to be incorrect.
- Navigate to the IAM & Admin page in the left-hand navigation bar in the Google Cloud console.
- Find the Compute Engine service account
<project_number>-firstname.lastname@example.org the App Engine service account
- Both service accounts must have the
Editorrole. If either account does not have the
Editorrole, update the role by clicking the pencil icon on the right of the account, clicking the dropdown of the existing role, scrolling up to the top and clicking Project, then Editor.
Insufficient quota - The production deployment consumes Compute Engine quota. If the project does not have enough quota, the deployment may time out while trying to provision resources.
- Navigate to the IAM & Admin page in the left-hand navigation bar in the Google Cloud console, then click the Quotas tab in the left-hand navigation bar.
- Near the top of the page, click the text box that says Filter table
and type in
Compute Engine API. Click the only result.
- Verify that all the quota statuses are within limit or have a green checkmark.
- Find and click into CPUs. Verify that the current usage plus the number of instances being deployed will still be below the limit for the deployment region.