Skip to content

GTM Server Side

GTM Server Side

This is the most complex implementation, and server container it's possible to implement it in multiple ways, like Google Cloud, Amazon Web Service, Stape, Taggrs or similars.

The guide will focus on easiest and most common solutions like Stape and Taggrs, if you want to deploy with Google Cloud or AWS solution, please refer to the official documentation, or contact us for custom integrations.

In summary, you need complete the next steps

  1. Create GTM Server Side Container
  2. Deploy Server Side Container with your preferred solution
  3. Create GTM Client Side Container
  4. Download and import Workspaces
  5. test validation

Create GTM Server Side Container

Deploy Server Side Container

Stape

Stape is a server-side container hosting solution that simplifies the process of deploying and managing server-side containers. It provides a user-friendly interface and various features to enhance performance and security.

If you do not have a Stape account, you can create one here. Once you have an account, follow the steps below to set up your server-side container.

Create a Stape Server Side Container

  1. In your Stape dashboard, click sGTM
  2. click on Create sGTM container

  1. Enter a container name (it doesn't have to match your GTM container name).
  2. Paste the Container Config you copied from GTM.
  3. Select a server location that's geographically close to your target audience.
  4. Click on Create Container.

  1. Choose a Stape plan (they offer a free tier to start).
  2. Click on Continue to proceed with the setup.
Setup Custom Domain

  1. Click Add custom domain.
  2. Enter a Domain name (e.g., stape.yourdomain.com).
  3. Enable Add CDN to improve the loading times
  4. Select Stape CDN or use your Own CDN
  5. Select Manually to get DNS Instructions
  6. Click Next to set up the custom domain.

Info

The Domain name is the value to set up on module configuration GA4 tab, Server Container URL input field.

  1. Set up the CNAME or A records and add it to your domain DNS settings.
  2. Click Verify in Stape to confirm the DNS are correctly deployed.

Info

The Verification process may take a few minutes, depending on your DNS provider.

Configure Stape Power-Ups

It is essential to set up at least the Custom Loader and GEO Headers

Custom Loader

Custom loader is a Stape feature that allows you to load the GTM container in a more efficient way, improving performance and reducing the impact of ad blockers.

  1. In your Stape dashboard, click over sGTM and select your GTM container.
  2. Click on Power-Ups tab.
  3. On Custom Loader panel click on Use.

  1. Enable the feature.
  2. Click on Save Changes.

  1. Select the Domain ( previously configured ).
  2. Add your Web GTM ID.
  3. Enable Ga4 ad block bypass.
  4. For Same Origin Path, check Stape documentation or contact support.
  5. Select Other Platform
  6. Set Data Layer Variable Name, leave it empty for default value.
  7. Select Generate with CDN
  8. Disable Use original GTM code.
  9. Click on Generate.
  10. Check the generated code and follow the next instructions.
Get GTM Server-side configuration from Stape Code

Warning

The stape code below is only an example do not use it, you must create your own code in your stape account.

Example Stape Script With Custom Loader
    <!-- Google Tag Manager -->
    <script>
        (function(w,d,s,l,i){
            w[l]=w[l]||[];
            w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});
            var f=d.getElementsByTagName(s)[0],j=d.createElement(s);
            j.async=true;
            j.src="https://load.metricstp.reactioncode.com/2rqhgioesoz.js?"+i;
            f.parentNode.insertBefore(j,f);
        })(window,document,'script','dataLayer','cnfl0o=aWQ9R1RNLVBLQjNIUTM%3D&apiKey=fbf0cf8');
    </script>

    <!-- End Google Tag Manager -->
  • Script URL: https://load.metricstp.reactioncode.com/2rqhgioesoz.js
  • Query ID Parameter: cnfl0o
  • Override Tracking ID: aWQ9R1RNLVBLQjNIUTM%3D&apiKey=fbf0cf8
GEO Headers

GEO Headers is a Stape feature that allows you to send the user's location to the server-side container, improving data accuracy and reducing the impact of ad blockers.

  1. In your Stape dashboard, click over sGTM and select your GTM container.
  2. Click on Power-Ups tab.
  3. On GEO Headers panel click on Use.

  1. Enable the feature.
  2. Click on Save Changes.

Taggrs

Coming Soon!

If you use Taggrs for Server-side, contact me on Addons to advance detailed support.

Create GTM Client Side Container

Download Server Side Workspaces

Download the Full Server Side Workspace Configurations (04/04/2025) to import it in your GTM Workspace. only since module version 3.4 and 4.4

Tip

Unzip the downloaded file to obtain the JSON files and be able to import it into Google Tag Manager

Import Workspaces

The workspaces provided in the zip are divided by tracking platforms. To ensure optimal performance and avoid unnecessary configurations, just import only the workspaces for the platforms you need:

Configure Constants Variables in Server-Side Workspace

For security reasons the module does not send the API keys in dataLayer, therefore depending on the tracking platform, it is essential to configure the constants variables in the server-side workspace to be able to send the data through the API platforms.

Platforms that requires to configure constants variables:

  • Criteo, see instructions to get the API key here.
  • Facebook, see instructions to get the API key here.
  • Pinterest, see instructions to get the API key here.
  • TikTok, see instructions to get the API key here.
  • Twitter, see instructions to get the API key here.

Once you have an API key, you can configure the constants variables in the server-side workspace. To do this, follow these steps:

  1. In your GTM server-side workspace, click on Variables.
  2. On search input, type API to filter the variables.
  3. Click on API - YOUR_PLATFORM / Access Token to edit the variable.

  1. In the Variable Configuration panel, select Constant as the variable type.
  2. In the Value field, paste the API key you obtained from the platform.
  3. Click on Save to save the changes.