Get started with server-side tagging¶
This guide walks you through the steps needed to get a server-side tagging container up and running, integrate it with your Usercentrics CMP, and get data flowing into server-side tags and third-party systems.
Watch our quick overview video below or follow the steps in this page to get started.
Create a server container¶
The server container needs to be created in two places: Google Tag Manager and Usercentrics Server-Side Tracking. They will be connected to each other and work in tandem: while Usercentrics provides the hosting infrastructure and other functionality, Google Tag Manager is used to set up your implementation (e.g. using clients, tags, transformations).
Create the container in Google Tag Manager¶
-
Go to Google Tag Manager, and sign in or create an account if you don't already have one.
-
Click on Create Container and under Target platform select Server.

-
Google Tag Manager will ask how you want to provision this server. Select Manually provision tagging server and then copy the Container Configuration string.

Create the container in Usercentrics Server-Side Tracking¶
-
Go to Usercentrics Server-Side Tracking, and sign in or create an account if you don't already have one.
-
If this is a new account, add your company's information
-
Click Create Container, give it a name and paste the container configuration string that was copied from Google Tag Manager.

-
Click the Create Container button to provision your new server-side tagging container. You will be taken to the container details page. You will see the container status go from 'Provisioning' to 'Active'.

At this point, the container is ready to be used. However, to truly reap the benefits of server-side tagging we need to make it available under a custom domain. We'll cover how to do that in the next section.
Add a custom domain¶
A key advantage of using a server-side container is that it can run in a first-party context. In practice, this means hosting it on a subdomain of your website(s). When set up this way, cookies placed by the server are considered first-party cookies, which makes them more secure and longer-lasting. As a result, your conversion tracking window is extended, and the data sent to your marketing platforms is more accurate and reliable.
Depending on your subscription plan, you may add one or multiple custom domains to your container. This needs two things: defining the domain(s) you want to use in the Usercentrics Server-Side Tracking platform, and configuring their DNS records appropriately.
To add a custom domain, follow these steps:
-
Under the container's details screen go to the Domains section, add the subdomain you would like to use and click Add domain. For example, if your brand's website is accessible at
example.com, then you could use something likesst.example.comordata.example.com.
-
After adding your domain for the container, go to your DNS provider and create a CNAME record with the corresponding host and value displayed for your entry.
Here are some documentation references on how to create DNS records for common providers: Wix, Cloudflare, WordPress.com, Namecheap, GoDaddy. If your vendor is not listed, search their support pages for "How to set up a CNAME record". -
When you've added your DNS settings, the domain will change from
PendingtoActivestatus (and turn green). This might take from a few minutes up to 72 hours, depending on your provider. You will be notified when the domain has been verified.
-
At this point, your container is accessible under your custom domain. Test that it's working by going to your browser and input the domain followed by the
/healthzpath. You should see anokresponse. This URL is a health-check endpoint that you can use any time to check if your container is operational.
-
To complete your custom domain setup, add it to your container's settings, so that's it accessible for debugging when using Preview mode. In Google Tag Manager, select Admin, then Container Settings. Click Add URL once, add the custom URL, and click Save.

Set up the data flow¶
Overview¶
Now that we have a fully deployed server Google Tag Manager container, it's time to start using it. There are two things you need to do:
-
Set up the client to send data to the server container: change your website's tag configurations to point to your new domain, instead of sending data directly to third-party services.
-
Use consent signals in the server container: make the service-level consent signals available to the server, so they can be used in trigger conditions for tags and transformations.
The next sections of this guide explain step-by-step how to do these task.
Looking at the diagram for server-side tagging, you may notice that there's a single connection going from the client to the server, through Google Analytics 4 (GA4). That is because the cleanest and easiest to maintain setup is to consolidate data flow under a single stream, and then trigger tags for different services on the server container.
Configure web GTM with Google Analytics as the client-to-server data stream¶
-
(Optional) If you don't already one, create a web container in Google Tag Manager. It's very similar to the process described above, but make sure to select the Web container type. Deploy it to your page following the instructions displayed in GTM.
-
(Optional) This example will use Google Analytics as the data stream, which needs the Google tag deployed to the website. If you don't already have it, add the Google Tag to your web container, set your Measurement ID, and set the Firing Trigger to Initialization - All Pages
-
The way the Google tag knows to communicate with your server-side container is through the
server_container_urlconfiguration variable. Under the tag's Configuration Settings section, click on Add parameter and then inputserver_container_urlas the name, and your container domain in the value field (e.g.https://demo.example.com).
-
Save your changes to the Google tag and go into preview mode in both your web and server containers. When your page loads in the web container's preview screen, you should see events going to your server container.
-
If you see requests coming into the server container, it means your Google tag is correctly setup and you can publish your web container changes.
If you're already using the Google Analytics tag, it should automatically send its data through your server container as well. If you're not using it yet, you will want to add it, to track other events and data attributes.
With this, the basic setup to get data flowing from the website to the server container is complete.
The next step is making sure to use consent signals in your server-side container. A recommended (optional) step is to have your container serve your Google scripts (gtm.js and gtag.js). . You can find more details about this in the next section.
Serve scripts from your container (optional, recommended)¶
We recommend serving Google scripts from your server container instead of their default source (googletagmanager.com). This gives you full control over user's data that reaches third-party services, and makes your setup more resilient to device restrictions.
To enable serving the Google Tag Manager script (gtm.js) and dependent ones like the Google tag (gtag.js) from your domain, follow these steps:
-
Add the Google Tag Manager Web Container client to your server container, select the web container IDs you enable, click Save and then Submit to publish your container changes.

-
Change your website's script that loads Google Tag Manager to point to your server container URL. So, substitute
www.googletagmanager.comwith your custom container domain (likedemo.example.com).
Configure apps with GA4 as the client-to-server data stream¶
Step 1: Preparation of Apps¶
Android
In your app's AndroidManifest.xml, paste the following code. Change APP_PACKAGE_ID to your app's actual package identifier (all lowercase).
<!-- Preview Activity to enable preview mode –->
<activity
android:name="com.google.firebase.analytics.GoogleAnalyticsServerPreviewActivity"
android:exported="true"
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tagmanager.sgtm.c.<APP_PACKAGE_ID>" />
</intent-filter>
</activity>
<!-- Meta-data that enables enables sGTM –->
<meta-data android:name="google_analytics_sgtm_upload_enabled" android:value="true" />
iOS
In your app's Info.plist paste the following code. Change BUNDLE_ID to your app's actual bundle identifier.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>None</string>
<key>CFBundleURLName</key>
<string>BUNDLE_ID</string>
<key>CFBundleURLSchemes</key>
<array>
<string>tagmanager.sgtm.c.BUNDLE_ID</string>
</array>
</dict>
</array>
<key>GOOGLE_ANALYTICS_SGTM_UPLOAD_ENABLED</key>
<true/>
Step 2: Preparation of Apps¶
Google Analytics Client
Go to your server-side GTM container and create a new client of the type GA4 (App). This client will handle the translation of the event data coming from your apps into common event data that the tags in your server-side GTM container can work with. There is no configuration needed on the client.

Tag Configuration
In general, all Google tags will work regardless of the origin of the data stream - be it web, or app, or even offline sources. However, there are two gotchas, you need to pay attention to when rolling out app data collection into an existing server-side GTM setup:
-
Check if the existing triggers will fire on the client that you created one step above. In case, your trigger includes the exact name of the client, such as
GA4 Web, you will need to adjust it to also include the new app client’s name -
Often, consent-logic is natively unique to the source of the data. Check if your consent blockers will work with the new app data, too.
Step 3: Change the Collection Endpoint¶
Finally, you will need to change the collection endpoint on your apps. This will happen in the setting of your app’s data stream within Google Analytics. Go to Admin > Data Streams and then pick the Android/iOs data stream that you want to start sending data to your server-side GTM. In the stream, enter the server-side Tag Manager configuration.

In the upcoming dialogue paste your server-side GTM's URL and set the percentage of traffic sent to it to 100%.

Move on to the next section: use consent signals in your server-side container.