Remote Command: Firebase
Tealium remote command integration for Firebase on Android and Swift/iOS
Requirements
- One of these mobile libraries:
- Tealium for Android-Kotlin (1.0.0+)
- Tealium for Android-Java (5.9.0+ for Firebase 2.0.0+ or <5.9.0 for previous versions)
- Tealium for iOS-Swift
- One of these remote command integrations:
- Firebase Remote Command JSON File (Requires Android-Kotlin 1.0.0+ or iOS-Swift 2.1.0+)
- Firebase Remote Command tag in Tealium iQ Tag Management
How It Works
The Firebase integration uses three items:
- The Firebase native SDK
- The remote commands module that wraps the Firebase methods
- Either the JSON configuration file or Remote Command tag that translates event tracking into native Firebase calls
Adding the Firebase remote command module to your app automatically installs and builds the required Firebase libraries, without having to add vendor-specific code to your app. If you are using a dependency manager installation, there is no need to install the Firebase SDK separately.
There are two remote command options: A JSON configuration file, or using iQ Tag Management to configure the mappings. A JSON configuration file is the recommended option for your vendor integration, hosted either remotely or locally within your app. If using iQ Tag Management, add the Remote Command tag for the vendor integration. Learn more about vendor integrations.
Install
Dependency Manager
- In your Xcode project, select File > Add Packages… > Add Package Dependency.
- Enter the repository URL:
https://github.com/tealium/tealium-ios-firebase-remote-command
. - Configure the version rules. Typically,
Up to next major
is recommended. If the currentTealiumFirebase
version does not appear in the list, then reset your Swift package cache. - Select the
TealiumFirebase
module to install, and select the app target you want the module to be installed in.
If your project has more than one app target and needs TealiumFirebase
module in more app targets, you have to manually add them in the Frameworks, Libraries, and Embedded Content section.
To install TealiumFirebase
in additional app targets:
- Select your Xcode project in the Project Navigator.
- In your Xcode project, select the app target under the TARGETS section.
- Navigate to General > Frameworks, Libraries & Embedded Content and select the
TealiumFirebase
module to add it to your app target.
To add additional modules from the Tealium Swift library, follow the Swift Package Manager instructions.
-
Remove the following line if it exists in your Podfile:
pod "Firebase/Analytics"
-
Add the following dependency to your Podfile:
pod "TealiumFirebase"
The
TealiumFirebase
pod includes the followingTealiumSwift
dependencies:'tealium-swift/Core' 'tealium-swift/RemoteCommands' 'tealium-swift/TagManagement'
-
Import the modules
TealiumSwift
andTealiumFirebase
in yourTealiumHelper
file, and any other files that access theTealium
class, or the Firebase remote command.
-
Remove
tealium-swift
from your Cartfile. The dependency fortealium-swift
is already included in theTealiumFirebase
framework. -
Remove the following line if it exists in your Cartfile:
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json"
-
Add the following dependency to your Cartfile:
github "tealium/tealium-ios-firebase-remote-command"
The TealiumFirebase
module cannot be built as an xcframework
when using the Carthage --use-xcframeworks
flag because Firebase uses a Carthage binary installation. It is recommended to use Carthage’s official Xcode 12 workaround to build the dependencies.
-
Install Tealium for Android (Kotlin) or Tealium for Android (Java) and add the Tealium Maven URL to your project’s top-level
build.gradle
file, if you haven’t done so already.allprojects { repositories { jcenter() maven { url "https://maven.tealiumiq.com/android/releases/" } } }
-
Add the following dependency your
build.gradle
file:dependencies { implementation 'com.tealium.remotecommands:firebase:1.2.0' }
-
Navigate to the root of your React Native project.
-
Download and install the
tealium-react-firebase
package with the following command:yarn add tealium-react-firebase
-
React Native Autolinking is enabled in version 1.0.7 of the NPM package and is no longer needed to run
react-native link
if using version 0.60+ of React Native.
Install the Tealium Firebase library for Xamarin directly from Visual Studio using the built-in NuGet package manager.
To install the Tealium Firebase library for Cordova, run the following command in your Cordova app project:
cordova plugin add tealium-cordova-firebase-plugin
Manual Installation
The manual installation for Firebase remote commands requires the Tealium for Swift library to be installed. To install the Firebase remote commands for your iOS project:
-
Install the Firebase SDK, if you haven’t already done so.
-
Clone the Tealium iOS Firebase remote command repo and drag the files within the
Sources
folder into your project. -
Set the
remoteAPIEnabled
configuration flag totrue.
The manual installation for Firebase remote commands requires Tealium for Android (Kotlin) or Tealium for Android (Java) to be installed.
To install the Firebase remote commands for your Android project:
-
Add
flatDir
to your project rootbuild.gradle
file:allprojects { repositories { jcenter() flatDir { dirs 'libs' } } }
-
Add
tealium-firebase.aar
to<PROJECT_ROOT>/<MODULE>/libs
. -
Add the Tealium library dependency to your
build.gradle
file:dependencies { implementation(name:'tealium-firebase', ext:'aar') }
Initialize
For all Tealium libraries, register the Firebase mobile remote commands when you initialize.
Initialize remote commands with a JSON configuration file or the Remote Command tag for Tealium’s iOS (Swift) library:
var tealium : Tealium?
let config = TealiumConfig(account: "ACCOUNT",
profile: "PROFILE",
environment: "ENVIRONMENT",
dataSource: "DATASOURCE")
config.dispatchers = [Dispatchers.TagManagement, Dispatchers.RemoteCommands]
config.remoteAPIEnabled = true // Required to use Remote Commands
tealium = Tealium(config: config) { _ in
guard let remoteCommands = self.tealium?.remoteCommands else {
return
}
// Webview Tag
let firebase = FirebaseRemoteCommand()
// Local JSON
//let firebase = FirebaseRemoteCommand(type: .local(file: "firebase"))
// Remote JSON
//let firebase = FirebaseRemoteCommand(type: .remote(url: "https://some.domain.com/firebase.json"))
remoteCommands.add(firebase)
}
Initialize remote commands with a JSON configuration file or the Remote Command tag for Tealium’s Kotlin library:
val config = TealiumConfig(application,
"ACCOUNT",
"PROFILE",
Environment.DEV,
dispatchers = mutableSetOf(Dispatchers.RemoteCommands, Dispatchers.TagManagement));
val firebase = FirebaseRemoteCommand(application);
var tealium = Tealium.create(TEALIUM_MAIN, config) {
// Webview Tag
remoteCommands?.add(firebase);
// Local JSON
//remoteCommands?.add(firebase, filename = "firebase.json");
// Remote JSON
//remoteCommands?.add(firebase, remoteUrl = "https://some.domain.com/firebase.json");
}
Initialize remote commands with the Remote Command tag for Tealium’s Android (Java) library:
RemoteCommand firebase = new FirebaseRemoteCommand(application);
teal.addRemoteCommand(firebase);
import FirebaseRemoteCommand from 'tealium-react-firebase';
// Webview Tag
let firebase = { id: FirebaseRemoteCommand.name }
// Local JSON
//let firebase = { id: FirebaseRemoteCommand.name, path: "firebase.json" }
// Remote JSON
//let firebase = { id: FirebaseRemoteCommand.name, url: "https://some.domain.com/firebase.json" }
let config = TealiumConfig {
// ...
remoteCommands: [firebase]
}
let Environment = tealium.utils.Environment;
let Dispatchers = tealium.utils.Dispatchers;
// Webview Tag
let firebase = window.tealium.remotecommands.firebase.create()
// Local JSON
//let firebase = window.tealium.remotecommands.firebase.create().setPath("firebase.json")
// Remote JSON
//let firebase = window.tealium.remotecommands.firebase.create().setUrl("https://some.domain.com/firebase.json")
let config = {
account: ACCOUNT_NAME,
profile: PROFILE_NAME,
environment: Environment.dev,
dispatchers: [
Dispatchers.TagManagement,
Dispatchers.RemoteCommands
],
remoteCommands: [
]
};
window.tealium.initialize(config, function(success) {
console.log("Init was: " + success)
})
// Webview Tag
var firebase = new FirebaseRemoteCommandIOS(new RemoteCommandTypeWrapper());
// Local JSON
//var firebase = new FirebaseRemoteCommandIOS(new RemoteCommandTypeWrapper("firebase", NSBundle.MainBundle));
// Remote JSON
//var firebase = new FirebaseRemoteCommandIOS(new RemoteCommandTypeWrapper("https://some.domain.com/firebase.json"));
var commands = new List<IRemoteCommand> {
firebase
};
TealiumConfig config = new TealiumConfig(ACCOUNT_NAME,
PROFILE_NAME,
ENVIRONMENT,
new List<Dispatchers> {
Dispatchers.RemoteCommands, Dispatchers.TagManagement
},
new List<Collectors> {},
remoteCommands: commands
);
// Webview Tag
var firebase = new FirebaseRemoteCommandDroid(this.Application, null, null);
// Local JSON
//var firebase = new FirebaseRemoteCommandDroid(this.Application, "firebase.json", null);
// Remote JSON
//var firebase = new FirebaseRemoteCommandDroid(this.Application, null, "https://some.domain.com/firebase.json");
var commands = new List<IRemoteCommand> {
firebase
};
TealiumConfig config = new TealiumConfig(ACCOUNT_NAME,
PROFILE_NAME,
ENVIRONMENT,
new List<Dispatchers> {
Dispatchers.RemoteCommands, Dispatchers.TagManagement
},
new List<Collectors> {},
remoteCommands: commands
);
JSON Template
If you are configuring remote commands using a JSON configuration file, refer to the following template to get started. The template includes common mappings used in a standard e-commerce installation. Edit the mappings as needed.
{
"config": {
"firebase_analytics_enabled": "true",
"firebase_session_timeout_seconds": "30",
"firebase_log_level": "max",
"firebase_session_minimum_seconds": "100"
},
"mappings": {
"achievement_id": "event.param_achievement_id",
"ad_network_click_id": "event.param_ad_network_click_id",
"affiliation": "event.param_affiliation",
"campaign_keywords": "event.param_cp1",
"campaign": "event.param_campaign",
"game_character": "event.param_character",
"checkout_option": "event.param_checkout_option",
"checkout_step": "event.param_checkout_step",
"content": "event.param_content",
"content_type": "event.param_content_type",
"coupon": "event.param_coupon",
"creative_name": "event.param_creative_name",
"creative_slot": "event.param_creative_slot",
"currency_code": "event.param_currency",
"travel_destination": "event.param_destination",
"end_date": "event.param_end_date",
"flight_number": "event.param_flight_number",
"group_id": "event.param_group_id",
"current_index": "param_index",
"product_brand": "items.param_item_brand",
"product_category": "items.param_item_category",
"product_id": "items.param_item_id",
"product_unit_price": "items.param_price",
"product_quantity": "items.param_quantity",
"product_list": "items.param_item_list",
"product_location_id": "items.param_item_location_id",
"product_name": "items.param_item_name",
"product_variant": "items.param_item_variant",
"current_level": "event.param_level",
"most_recent_location": "event.param_location",
"campaign_medium": "event.param_medium",
"number_nights": "event.param_number_nights",
"number_pax": "event.param_number_pax",
"number_rooms": "event.param_number_rooms",
"travel_origin": "event.param_origin",
"score": "event.param_score",
"search_keyword": "event.param_search_term",
"order_shipping_amount": "event.param_shipping",
"signup_method": "event.param_signup_method",
"campaign_source": "event.param_source",
"start_date": "event.param_start_date",
"order_tax_amount": "event.param_tax",
"product_term": "event.param_term",
"order_id": "event.param_transaction_id",
"travel_class": "event.param_travel_class",
"order_total": "event.param_value",
"currency_type": "event.param_virtual_currency_name",
"user_signup_method": "event.param_user_signup_method",
"event_title": "firebase_event_name",
"screen_name": "firebase_screen_name",
"screen_class": "firebase_screen_class",
"customer_property": "firebase_property_name",
"customer_value": "firebase_property_value",
"customer_id": "firebase_user_id"
},
"commands": {
"launch": "config",
"user_login": "logevent",
"user_register": "logevent,setuserproperty",
"share": "logevent",
"show_offers": "logevent",
"join_group": "logevent",
"travel_order": "logevent",
"earn_currency": "logevent",
"spend_currency": "logevent",
"unlock_achievement": "logevent",
"level_up": "logevent",
"start_tutorial": "logevent",
"stop_tutorial": "logevent",
"record_score": "logevent",
"category": "logevent,setscreenname",
"product": "logevent,setscreenname",
"cart_add": "logevent",
"wishlist_add": "logevent",
"checkout": "logevent,setscreenname",
"checkout_progress": "logevent",
"email_signup": "logevent",
"order": "logevent,setscreenname"
}
}
Track
Events triggered by basic interactions with your app are tracked automatically. Learn more about Firebase automatically collected events.
Learn about Firebase Mobile Remote Command Tag setup.
This page was last updated: March 14, 2023