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:

  1. Preparing your mobile app for server-side tagging
  2. Configuring your server container to support mobile traffic
  3. 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:

  1. Install the latest Firebase SDK

    Ensure you’re using the most recent version of the Google Analytics for Firebase SDK in your iOS application.

  2. 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.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    ...
            <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/>
    </dict>
    </plist>
    
  3. Configure URL handling

    To enable debug or preview mode, add a call to Analytics.handleOpen(_:) to pass the launch URL:

    For SwiftUI applications:

    @main
    struct MyApplication: App {
      var body: some Scene {
        WindowGroup {
          ContentView()
            .onOpenURL { url in
              Analytics.handleOpen(url)
            }
        }
      }
    }
    

Android Setup

Follow these steps to prepare your Android app for server-side tagging:

  1. Install the latest Firebase SDK

    Ensure you’re using the most recent version of the Google Analytics for Firebase SDK in your Android application.

  2. 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.

    <!-- 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 uploads to sGTM -->
    <meta-data android:name="google_analytics_sgtm_upload_enabled" android:value="true" />
    

Step 2: Configure Your Server Container for Mobile Traffic

This section assumes you have an existing server-side tagging deployment and are familiar with its concepts.
1

Set up the Google Analytics: GA4 (App) client

  1. In your server container, navigate to Clients and click New.
  2. Click Client Configuration, then select Google Analytics: GA4 (App).
  3. Enter a name for your client (e.g., “GA4 App Client”) and click Save.
2

Configure your Google Analytics: GA4 tag

  1. In your server container, go to Tags and click New.
  2. Click Tag Configuration, then choose Google Analytics: GA4.
  3. Keep the default settings, as the tag will inherit all relevant fields and parameters from the event data object created by the client.
3

Set up triggers for mobile traffic

  1. In the tag settings, click Triggering.
  2. Click the + icon in the top right corner to create a new trigger.
  3. Click Trigger Configuration to choose the trigger type.
  4. Select Custom from the list.
  5. Select Some Events to enable activation conditions for this trigger.
  6. Click on the Event Name selector and select Choose Built-In Variable.
  7. Select the Client Name variable.
  8. Set the condition to equals and enter the name of your GA4 App client (e.g., “GA4 App Client”).
  9. Save the trigger with a descriptive name (e.g., “All GA4 App Events”).
  10. Back in the tag settings, save the tag with a descriptive name (e.g., “GA4”).
4

Preview your container

You can preview and debug your server container before publishing changes:

  1. Select Preview while in your server container.
  2. Click the More Actions icon (⋮) and select Send requests from an app.
  3. Enter your app ID and click Generate QR Code.
  4. Scan the QR code with your phone’s camera app.
  5. Interact with your app to generate preview events.
  6. Click OK to close the dialog.
5

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

1

Access your GA4 property settings

  1. In your Google Analytics 4 property, go to Admin.
  2. Open Data streams.
  3. Select your application’s stream configuration from the iOS or Android tab.
2

Configure server-side Tag Manager

  1. Click Configure SDK settings, then Configure server-side Tag Manager.
3

Enable and configure the integration

  1. Toggle Send data to a server-side Tag Manager container.
  2. 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).
  3. 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%.
  4. 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)