Setup Google Cloud project for hosting server side container
This is where you will have the GCP project that will house the Server Side GTM container.
Create a new Google Project if you don’t already have one setup.
Configure your billing account for that project.
In the side menu, click App Engine.
Enable App Engine and select the location to run your App Engine instances.
NOTE: Once this location has been selected, it CANNOT BE CHANGED. Select your location carefully.
Setup Server Side Container
Setting up a server side tagging involves deploying a Tag Manager container to an AppEngine instance hosted by the same domain as your website. This is what differentiates standard Tag Manager from server side Tag Manager. The App Engine instance will provide an endpoint on your domain that handles all of your tagging requests sent by your website. These requests will then be forwarded to the appropriate analytics platforms.
The first step in setting up the server side container is to create the container config in Google Tag Manager.
In your Tag Manager account, click the plus button under Containers in the Admin menu.
Name the container appropriate and select the Server option.
Once the container is created, you will be prompted to provision the hosting server either manually or automatically.
Automatic Installation
Server side GTM provides an option for you to automatically provision an App Engine service to host your server side container. Follow the steps below to configure using this option:
Select the automatic option for installing your server side container. You will be prompted to set up your billing account. Follow the instructions on screen to configure your billing account.
Once your billing account is configured, select your billing account in the dropdown menu and click Select billing account and create server. This may take a few minutes to complete.
Once the server is provisioned, the details of the server will be displayed for you. Make sure you take note of the Default Url and the Google Cloud Platform Project ID for use later on.
Manual Installation
When selecting the manual installation option, you will need to follow these instructions to provision an App Engine instance. You will need to copy the config ID from your container in Tag Manager when prompted by the script from the instructions above.
After the App Engine instance is installed, navigate to the Admin → Container Settings menu in Tag Manager and enter the url of your App Engine instance in the Tagging server URL field and click Save.
To verify this worked, click the Preview button on the container dashboard and it should take you to the preview page on your newly deployed App Engine url. If you have done anything incorrectly, preview mode will not open.
Configure subdomain to point to server side instance
In order for server side tracking to work as described, a subdomain will need to be added to your Domain Name Server for the same domain that your site is hosted in. For example, if your site is hosted at www.bunnings.com.au, you will need to create a subdomain for bunnings.com.au which could be tracking.bunnings.com.au. Below are some generic steps required to set this up:
In your Google Cloud Project, open up App Engine via the side menu.
Go to the Settings menu using the side bar and click Custom Domains.
Next, click Add a custom domain.
Under the Select the domain you want to use, click the dropdown menu and select Verify a new domain.
Enter in your new custom domain (e.g analytics.example.com) and click Verify.
You will then be taken to a window where you can select the provider of your domain. You will need to follow the instructions given to you on screen as each provider verifies domains differently.
Once the domain has been successfully verified you can click Continue.
Ensure that only your custom domain (analytics.example.com) is in the list of mapped domains for section 2 and click Save mappings then Continue.
Finally you will need to enter all the DNS records from the Update your DNS records to enable security section with your domain registrar.
Once configured, it could take up to 48 hours for this subdomain to become available.