Search specific term/phrase surrounded by double quotes. e.g. “deep linking”
Exclude records that contain a specific term prefixed with a minus. e.g. Android -Firebase

GTM iOS Setup

Steps for using Google Tag Manager with the Branch iOS SDK.


You can use Google Tag Manager (GTM) to trigger specific actions related to Branch.

This guide walks you through how to do this for your iOS app, in combination with the Branch iOS SDK.

More specifically, you will learn how to create and log Branch Events.


In order to use GTM and Branch together, you first need to:

  1. Create a GTM account that has a container with "iOS" as the chosen platform.
  2. Integrate the Branch iOS SDK into your iOS app.


Import GTM

Add the following line to your podfile to import the GTM library:

pod 'GoogleTagManager', '~> 6.0'

To learn more about how to set up your podfile, visit the iOS Basic Integration guide and review the CocoaPods steps.

Create Custom Class

You'll now need to write a class that includes your Branch code. This is the code that GTM will be configured to call.

Create a class that extends NSObject and implements TAGCustomFunction.

In this example, the class will create and log a Branch PURCHASE Event when triggered by GTM.

Note the path to this class in your code. You'll need it when you create your tag in GTM.

Implement Branch Features

Track Events

1. Create a Trigger

Create a new trigger that is associated with a Firebase event.

  1. In the Workspace tab, click on Triggers.

  2. Click New, and create a trigger with type Custom Event.

  3. Provide an event name and configure when you want the trigger to fire.

  4. Click Save.

2. Create a Tag

Create a new tag, which will describe what you want to have occur when the trigger fires.

  1. In the Workspace tab, click on Tags.

  2. Click New, and create a tag with type "Function Call".

  3. For the Class Path field, add the path that leads to your custom class that calls Branch Event code.

  4. In the Key and Value sections, add your relevant variables.

  5. In the Triggering section, add the trigger you just created.

  6. Click Save.

3. Deploy GTM Changes

Deploy the changes you have made on the GTM side. Once you do this, the Branch Event creation and logging code will run every time the GTM tag is fired.

5. Trigger Firebase Event

In your code, trigger the Firebase event associated with the GTM trigger you created.

let parameters: [String: Any] = [
	AnalyticsParameterCurrency: "EUR",
	AnalyticsParameterValue: 100
Analytics.logEvent(AnalyticsEventPurchase, parameters: parameters)
NSDictionary *parameters = @{
    AnalyticsParameterCurrency: @"EUR",
    AnalyticsParameterValue: @100

[Analytics logEvent:AnalyticsEventPurchase parameters:parameters];



To make sure you've successfully set up GTM to work with the Branch iOS SDK:

  1. Trigger the event you are interested in, based on the trigger you set up in GTM.
  2. Go to the Liveview page of the Branch Dashboard.
  3. Filter the dropdown to the relevant event type that you are interested in, such as "custom event".
  4. Check to make sure that the event is being triggered with the expected details.

Enable Branch iOS SDK Logging

Make sure you have logging enabled within the Branch iOS SDK so you can see logs related to the Branch Event.

For steps on how to do this, visit our Branch iOS SDK Testing guide.


Visit our FAQs section to learn more about implementing Branch with GTM.