App Engine Setup Guide

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.

The process involves:

  1. Creating a Google Cloud Platform Project or navigating to an existing project in Google Cloud Console.
  2. 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 each server can handle 100 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 GCP 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.
screenshot of GCP project selector, showing a sample Tag Manager project ID.

If you did not create a GCP 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

  1. Open the Google Cloud Platform Cloud Shell
  2. 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>
    
  3. 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:

    1. If you have not set up a tagging server yet, this script will help you set it up.
    2. If you want to start serving production traffic from an existing tagging server, this script will help you add additional servers.
    3. If you have an existing tagging server, this script will help you change the configuration.

Configure the Tagging Server 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. Paste that URL into the Tagging server URL, click Save and navigate back to your workspace.

Validation

In Tag Manager, preview the container. If the preview page loads, then everything is set up correctly.

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:

  1. Navigate to the Logging -> Logs Router. Make sure you're in the project that matches your container ID:
    screenshot of GCP project selector, showing a sample Tag Manager container ID.
  2. For the Type: Cloud Logging bucket, Name: _Default line, select the overflow menu, then click Edit Sink
  3. Under Sink destination, select logs bucket _Default
  4. Under Choose logs to filter out of sink, click Add Exclusion
  5. Give the rule a name, set Exclusion filter rate to 100, and add this text to the Build an exclusion filter box: LOG_ID("appengine.googleapis.com/nginx.request") OR LOG_ID("appengine.googleapis.com/request_log") screenshot of GCP logs exclusion filter showing the specified configuration.
  6. Click Update Sink button at the bottom

Now the App Engine request will be excluded from logging. Check the Logging -> Logs Viewer to ensure that new requests are not appearing in the logs.