of Automatic provisioning process of Google Tag Manager server-side tagging service Very convenient.
With just a few clicks of a button, you can have a fully functional server-side tagging endpoint on Google Cloud Platform (GCP) (but for test use only).
For a video overview of automated deployments, see: this video.
However, the automatic provisioning process New Google Cloud Platform project Also, at the time of writing, the App Engine application (where the tagging server is running) is always us-central-1
Google Cloud region.
The latter can be especially problematic if you have a lot of traffic from locations outside the US. The longer the network traffic route, the more you have to pay. Once the App Engine application’s region is set it cannot be changed.
This article will show you how. Create a tagging server manually It can be either an existing GCP project or a brand new project you created.
Among other things, this way Select the geographic region of the tagging server During the provisioning process, unless the project has a previously deployed App Engine application.
It’s basically the same process you follow if: Upgrade the server to productionthe difference is that it takes a little more manual work to get things up and running.
X
shimmer newsletter
Subscribe to our Simmer newsletter to receive the latest news and content from Simo Ahava right in your email inbox!
Add your application to your GCP project
Since you’re building the application manually, do one of the following: I already have a Google Cloud Platform project I want or want to add a server container application create a completely new project for this application.
Whichever route you take, you have to do two things.
first, Cloud build API page by following this linkThen make sure you are in the correct project and finally select Effectiveness Enable APIs.
Then change the project to billing account As below this linkBilling must be enabled for the project in order for the provisioning setup to work.
Open your project in Google Cloud Console
Double check that you are in the correct project in the Google Cloud Console.
find the project at cloud resource manager Click to open.
Check out previous App Engine applications
before proceeding App Engine Dashboard of the project. If you see a suitable dashboard with data from your existing application, be warned.
When trying to add a GTM Server application to a project that contains an existing App Engine app, the GTM Server completely overwrites the previously installed service.
Be sure to tell the application owner that this is about to happen.
Run the upgrade script
Once you’ve verified and double-checked that your App Engine application can be installed in your project, you can run the script that handles the provisioning process.
The next chapter outlines the steps you need to take.
Open Cloud Shell
In the Google Cloud console for the project where you want to create your application, cloud shell Click the dedicated icon on the top bar.
Cloud Shell is a command-line shell prompt where you can run commands and run scripts. for all Google Cloud API components Pre-installed. So you don’t have to worry about installing dependencies like: gcloud
Because they are all pre-configured.
You are can Although you’ll perform most of these tasks outside of Cloud Shell (such as a local shell prompt or Google Cloud console), running the upgrade script in Cloud Shell means you don’t have to worry about: Any of the overhead of setting up the necessary tools and dependencies.
If you see a prompt like the one above, be sure to click it. approve Give Cloud Shell all necessary access to your Google Cloud project.
run the script
Once the shell instance has finished loading, you will see the command line interpreter inside your GCP project.
Now copy paste the following shell commandpaste it into the Cloud Shell command line, and press Enter.
bash -c "$(curl -fsSL https://googletagmanager.com/static/serverjs/setup.sh)"
double check official document Make sure you are running the latest version of the shell command. Of course, we will make sure this guide is as up-to-date as possible.
This script was created by Google and contains all the Google Cloud API commands you need to create an App Engine application in your project.
If you already have an App Engine application in your project and that application was not a previous GTM server, you will see the following warning:
Remember to press . y
the previous application will be removed and replaced by the GTM server. Please proceed only if you have permission to do so.
Copy the container configuration string
The first setting that should respond is container configurationThis links your Google Cloud project (GTM server endpoint) to your Google Tag Manager container.
This setting allows you to control GTM server behavior through the familiar Google Tag Manager user interface.
to find container configurationnavigate to the Google Tag Manager container where you want to create the GTM server and click the container ID in the header.
Or if you’re just in the process of Create a new containerwhen you reach Install Google Tag Manager overlap, do No click Automatically provision tagging server
. instead of, Manually provision tagging server
.
Either way, the overlay will appear where the overlay should appear. container configuration (Also container configuration) is displayed. A meaningless alphanumeric string.
copy put it in the clipboard paste Enter this into the Cloud Shell and you will be prompted for a Container Config.
Configure the rest of the upgrade script
Specify the remaining configuration for the upgrade script.
Constitution | explanation | Note |
---|---|---|
Policy script URL | the URL policy script if you wish. | option. |
request logging | Whether App Engine logs all incoming HTTP requests to the GTM server. | If you find that logging costs are accumulating, you can optimize your logging. |
Deployment type | testing Launch a single App Engine standard instance. production Launch additional App Engine flexible instances. |
Please do not use testing If you want to handle production traffic. |
auto scaling | Whether the system automatically scales up instances to accommodate traffic spikes. | That’s why production deployment. |
Minimum number of servers | Minimum number of App Engine flexible instances at any given time. | That’s why production deployment. |
Maximum number of servers | The maximum number of App Engine flexible instances that the system can autoscale. | That’s why production deployment. |
CPU target utilization | The CPU utilization threshold (between 0.0 and 1.0) before a new App Engine instance is scaled up. | That’s why production deployment. |
Here’s an example of what the configuration might look like:
If you are ready to continue, enter y
and press enter.
Choosing an App Engine region
If you already have or are creating an application in a project that had a previous App Engine application, You can no longer change regionsAn App Engine region is set to valid when it is first created. Currently the only option is to create a new project from scratch.
If this is a brand new App Engine application, you can choose a geographic region for your application.
There are many things to consider when doing this, but the most important questions are: Which regions do the majority of requests come from?For example, if the majority of your traffic is from the United States, you should select the United States region. If your bulk is from Europe, you must select the EU region.
If you’re unsure, fluctuating, or fairly uniform in distribution, choose the region closest to you.
Regional Choices Have an Impact Network egress costsimilar to when an App Engine application needs to send HTTP requests across regions, it costs more than if the requests were made within the current region.
test the endpoint
Once the script has run (which will take a few minutes), you can: test the endpoint.
By configuring container configuration The upgrade script requires your App Engine application to process requests to the server container.
Of course, if you haven’t created any clients or tags, your endpoint is actually conduct everything.
A quick way to test that your endpoint is configured correctly to your GTM server is:
- While cloud shelltype
gcloud app browse
and press enter. This will serve the custom URL set for the endpoint as a link. - Click the link to open the endpoint URL in a new tab. HTTP error 400 page.
- add path
/healthy
To URL – A page with a message will be displayed.ok
.
of HTTP ERROR 400
It means that there was no client requesting the request.of /healthy
Endpoints are built into the GTM Server application and are used to ensure that the GTM Server is working properly.
Reconfigure your Google Tag Manager container
Finally, you need to tell your Google Tag Manager container the new URL for your endpoint.
For testing, continue appspot.com
URLs. However, you should configure your endpoint with a custom domain as soon as possible (see this chapter for some reasons).
To configure the GTM container to always open preview mode with the new App Engine application URL, go to: administrator In the GTM UI, container settings. here, appspot.com
(or custom domain) URL in the respective field.
Note that you can actually configure multiple URLs for your endpoint. See this article for more details.
Overview
This article described the steps necessary to manually set up your App Engine application for Google Tag Manager servers.
in most cases, Automatic provisioning process More than enough to get things started. However, if you want to set the App Engine region to another region, us-central-1
you Must Run the manual upgrade setup.
Similarly, if you want to install your application into an existing GCP project, Must Run the manual upgrade setup.
We hope to improve the automatic provisioning process in the future to allow for project and region selection as well.