sGTM for Mobile Apps
A comprehensive guide to configuring server-side tagging in Google Tag Manager for iOS and Android applications
This guide is based on the official Google documentation for server-side tagging for mobile apps. Please refer to original document for up-to-date information.
Overview
Server-side tagging allows you to process data collected by your mobile applications through a server container before forwarding it to your analytics platforms. This approach offers several benefits over traditional client-side implementations:
- Enhanced Privacy: Process and filter sensitive data before it reaches third-party tools
- Improved Reliability: Bypass ad blockers and tracking prevention measures
- Better Performance: Reduce mobile app network overhead by consolidating tracking calls
- Greater Control: Transform, enrich, and validate data before sending it to destinations
This guide will walk you through setting up server-side tagging for your iOS and Android mobile applications using Google Tag Manager.
Prerequisites
Before you begin the setup process, ensure you have:
- Integrated the Google Analytics for Firebase SDK in your mobile app (connected to a Google Analytics 4 property)
- A Google Tag Manager account with a server container
- Hardal Account
If you haven’t completed these prerequisites, please refer to the following resources:
Implementation Steps
Setting up server-side tagging for mobile apps involves three main steps:
- Preparing your mobile app for server-side tagging
- Configuring your server container to support mobile traffic
- Enabling server-side tagging in your GA4 property
Let’s walk through each step in detail.
Step 1: Get Your App Ready for Server-Side Tagging
iOS Setup
Follow these steps to prepare your iOS app for server-side tagging:
-
Install the latest Firebase SDK
Ensure you’re using the most recent version of the Google Analytics for Firebase SDK in your iOS application.
-
Update Info.plist
Enable the server-side tagging upload feature and set up the custom URL scheme for server-side tagging debug mode in your Info.plist file. Replace
BUNDLE_ID
with your app’s bundle identifier. -
Configure URL handling
To enable debug or preview mode, add a call to
Analytics.handleOpen(_:)
to pass the launch URL:For SwiftUI applications:
Android Setup
Follow these steps to prepare your Android app for server-side tagging:
-
Install the latest Firebase SDK
Ensure you’re using the most recent version of the Google Analytics for Firebase SDK in your Android application.
-
Update AndroidManifest.xml
Enable server-side GTM by adding the following to your application’s AndroidManifest.xml file. Replace
<APP_PACKAGE_ID>
with your app’s package name.
Step 2: Configure Your Server Container for Mobile Traffic
Set up the Google Analytics: GA4 (App) client
- In your server container, navigate to Clients and click New.
- Click Client Configuration, then select Google Analytics: GA4 (App).
- Enter a name for your client (e.g., “GA4 App Client”) and click Save.
Configure your Google Analytics: GA4 tag
- In your server container, go to Tags and click New.
- Click Tag Configuration, then choose Google Analytics: GA4.
- Keep the default settings, as the tag will inherit all relevant fields and parameters from the event data object created by the client.
Set up triggers for mobile traffic
- In the tag settings, click Triggering.
- Click the + icon in the top right corner to create a new trigger.
- Click Trigger Configuration to choose the trigger type.
- Select Custom from the list.
- Select Some Events to enable activation conditions for this trigger.
- Click on the Event Name selector and select Choose Built-In Variable.
- Select the Client Name variable.
- Set the condition to equals and enter the name of your GA4 App client (e.g., “GA4 App Client”).
- Save the trigger with a descriptive name (e.g., “All GA4 App Events”).
- Back in the tag settings, save the tag with a descriptive name (e.g., “GA4”).
Preview your container
You can preview and debug your server container before publishing changes:
- Select Preview while in your server container.
- Click the More Actions icon (⋮) and select Send requests from an app.
- Enter your app ID and click Generate QR Code.
- Scan the QR code with your phone’s camera app.
- Interact with your app to generate preview events.
- Click OK to close the dialog.
Publish your container
After verifying that everything works as expected in preview mode, publish your container to make the changes live for all traffic.
Step 3: Enable Server-Side Tagging in Your GA4 Property
Access your GA4 property settings
- In your Google Analytics 4 property, go to Admin.
- Open Data streams.
- Select your application’s stream configuration from the iOS or Android tab.
Configure server-side Tag Manager
- Click Configure SDK settings, then Configure server-side Tag Manager.
Enable and configure the integration
- Toggle Send data to a server-side Tag Manager container.
- Enter your server container URL (found in Google Tag Manager under Admin > Container Settings > Server container URLs) (also found in Hardal Dashboard > Server-Side-Hosts > Tagging URL for sGTM).
- Select the percentage of traffic you want to route to the server container. Start with a smaller percentage to validate your setup before scaling to 100%.
- Click Save.
Known Limitations
When implementing server-side tagging for mobile apps, be aware of these limitations:
For Android Applications:
- Automatically logged in-app purchases that rely on integration with the Google Play backend won’t be sent to the server container
- The
app_remove
event won’t be reported - Connecting your app data streams in Google Analytics to your Google Ads account is still necessary to ensure data and conversions are imported into Google Ads
Version History
- April 2025: Initial documentation release based on Google’s server-side tagging for mobile apps documentation (last updated February 2025)