DocsFor Apps
Install

Installing Trackingplan in Your Apps

Install Trackingplan in your iOS and Android apps with Swift Package Manager, CocoaPods or Gradle, including Flutter and Ionic apps, step by step.

For apps, you install Trackingplan’s iOS SDK, Android SDK or both. Replace YOUR_TP_ID with your Trackingplan ID, which your install page shows.

In this section:

This page uses the latest versions at the time of writing: 2.1.1 for iOS, and 3.1.1 for Android with its Gradle plugin at 2.2.0. Check for newer ones in our official repositories:

Trackingplan only sees the tracking your app sends after it starts, so start it before the SDK of any destination (Firebase, Adjust and the rest).

iOS SDK

The iOS SDK requires iOS 14 or later.

Installing Trackingplan’s iOS SDK using Swift Package Manager

With Trackingplan for iOS, you can check your tracking works as planned without changing your analytics stack or your code. Trackingplan monitors the traffic between your app and your data destinations and sends you warnings when something changes or breaks in your analytics, such as hit drops, missing properties, rogue events and more.

The recommended way to install Trackingplan for iOS is Swift Package Manager: it makes installing and upgrading Trackingplan simpler. Follow these steps.

  1. In Xcode, add the Trackingplan dependency with File → Add Package Dependencies... (File → Swift Packages → Add Package Dependency... in older versions of Xcode)
  2. If you’re asked to choose a project, select the project you want to add Trackingplan to. If not, proceed to step 3.
  3. When choosing a package repository, copy and paste https://github.com/trackingplan/trackingplan-ios into the search box and click Next.
  4. Choose Version and keep the default, the latest version (2.1.1 or later).
  5. Check the box next to Trackingplan and click Finish.
  6. Verify that the Trackingplan library has been added to the Swift Package Dependencies section.
  7. In your application delegate, import the SDK and start it at the beginning of application(_:didFinishLaunchingWithOptions:), before the SDK of any destination:
// AppDelegate.swift
import Trackingplan

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    Trackingplan.initialize(tpId: "YOUR_TP_ID")
    // ... the rest of your setup, after Trackingplan

    return true
}

All set. You have installed the Trackingplan iOS SDK. Now check that Trackingplan is collecting data correctly, so you know it is monitoring and documenting all the customer data you use for analytics, marketing and sales.

Installing iOS SDK with CocoaPods

Trackingplan also supports iOS installation using CocoaPods. Here is how.

  1. Add the Trackingplan dependency to your Podfile, then run pod install:
pod 'Trackingplan', :git => 'https://github.com/trackingplan/trackingplan-ios.git', :tag => '2.1.1'
  1. Import the SDK and start it in application(_:didFinishLaunchingWithOptions:), exactly as with Swift Package Manager.

That’s it. Now check that Trackingplan is collecting data correctly.

Installing iOS SDK in a Flutter project

You can manage the Trackingplan iOS dependency with CocoaPods.

Your Flutter project is not using CocoaPods yet?

  • Move to the iOS folder inside your Flutter project folder. {project_name}/ios/
  • Initialize CocoaPods: $ pod init: this will create the Podfile.

Install:

  • Open the Podfile, uncomment the platform line at the top and set it to iOS 14 or later: platform :ios, '14.0'
  • Add a line for the Trackingplan pod inside the target block:
    • pod 'Trackingplan', :git => 'https://github.com/trackingplan/trackingplan-ios.git', :tag => '2.1.1'
  • Make sure that use_frameworks! is in place.

Sample Podfile (Project without CocoaPods):

platform :ios, '14.0'

...

target 'Runner' do
  use_frameworks!
    # Pods for Runner
  pod 'Trackingplan', :git => 'https://github.com/trackingplan/trackingplan-ios.git', :tag => '2.1.1'
end
  • Move to the ios folder path {project_name}/ios/ and run the command $ pod install

Sample Podfile (Project already using CocoaPods):

target 'Runner' do
  use_frameworks!
  use_modular_headers!
  pod 'Trackingplan', :git => 'https://github.com/trackingplan/trackingplan-ios.git', :tag => '2.1.1'
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

Setup:

  • Include Pods files in debug and release config:
    • Edit the file {project_name}/ios/Flutter/Debug.xcconfig and add at the end:

      #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"

    • Edit the file {project_name}/ios/Flutter/Release.xcconfig and add at the end:

      #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"

  • Update AppDelegate.swift in {project_name}/ios/Runner/: add import Trackingplan at the top, and call Trackingplan.initialize(tpId: "YOUR_TP_ID") at the beginning of didFinishLaunchingWithOptions.

Installing Trackingplan in Ionic for iOS platform

To use Trackingplan in an Ionic app, you set it up on each platform. It works much like installing Trackingplan in any mobile app.

Once that's done, Trackingplan captures and monitors every tracking request from any version of the app.

These instructions are for Capacitor Ionic apps, but they capture data from any analytics and marketing SDK, whether it is Capacitor, Cordova or JS. For Cordova apps without Capacitor, the installation is very similar.

  1. Open the Podfile and set the platform at the top to iOS 14 or later.
  2. Add the following lines for the Trackingplan pod inside the target block:
    use_frameworks!
    use_modular_headers!
    pod 'Trackingplan', :git => 'https://github.com/trackingplan/trackingplan-ios.git', :tag => '2.1.1'
  3. Move to the ios/App folder and run:
    pod install
  4. Update AppDelegate.swift in ios/App/App to import Trackingplan at the top:
    import Trackingplan
  5. Start Trackingplan with your Trackingplan ID at the beginning of the didFinishLaunchingWithOptions function:
    Trackingplan.initialize(tpId: "YOUR_TP_ID")
  6. Run the following commands:
ionic build
npx cap sync ios
npx cap run ios

Installing Trackingplan in Ionic for web apps

You need this step if your analytics and marketing use JS SDKs instead of native ones (Cordova, Capacitor), or if you publish your app as a website.

  1. Add the Trackingplan snippet to your app's index.html.
  2. You'll find the snippet on the Head tab of your install page. See the instructions here.

iOS advanced options

Trackingplan.initialize takes these optional parameters, by name. Swift requires them in this order: leave out the ones you don't need, but don't reorder the rest.

ParameterDescriptionDefault
environmentIsolates the data of production and testing environments."PRODUCTION"
tagsTags for the data sent to Trackingplan, as a [String: String] dictionary of tag names and values.[:]
sourceAliasTells your sources apart."ios"
customDomainsExtends the list of monitored domains, as a [String: String] dictionary of domains and parser IDs. See custom domains.[:]
debugPrints debug information in the console.false
dryRunSends nothing to Trackingplan, so you can test the SDK. Requires debug: true, or the SDK does not start.false
trackingplanEndpointWhere Trackingplan sends your data. Set it only if your plan is not in the EU datacenter: contact us for its value.EU datacenter

For example:

Trackingplan.initialize(
    tpId: "YOUR_TP_ID",
    environment: "development",
    tags: ["country": "us"],
    sourceAlias: "iOS app"
)

To change tags after Trackingplan has started, for example when the user changes country, call Trackingplan.updateTags(["country": "uk"]). New values replace the old ones for the same tag.

Automatic tagging. For iOS and Android SDKs, the app_version tag is included automatically, with no extra setup. Add any other tag, such as country, build number or test name, with the tags option.

Using Custom domains

Trackingplan recognizes requests sent to the standard collection domains of the analytics and marketing platforms it supports, automatically. Each domain maps to a Trackingplan parser, which turns the raw requests into the enriched event format you see across the platform.

If your implementation sends data to a custom collection domain instead of the platform's default one, Trackingplan can't identify it automatically. In that case, configure the custom domain when you install Trackingplan.

To configure a custom domain, you need:

  • The custom domain that your implementation sends requests to (for example, your own collection domain instead of the platform's default endpoint).
  • The parser ID that tells Trackingplan which platform those requests belong to.

The parser value is not the name you'll see in Trackingplan. It is the internal identifier that tells Trackingplan how to read requests from that domain.

Some common parser IDs include:

Platform

Parser ID

Server-side Google Tag Manager

ssgtm

Stape

stape

Tealium

tealium

Adobe Analytics

adobe

Adobe Target

adobe_target

Jentis

jentis

Piano

piano

Android SDK

The Android SDK requires minSdk 24 (Android 7.0) or later and Android Gradle Plugin 8.0.2 or later.

Installing Trackingplan’s Android SDK using Gradle

With Trackingplan for Android, you can check your tracking works as planned without changing your analytics stack or your code.

  1. In Android Studio, expand the Gradle Scripts section.
  1. In the project-level build.gradle.kts, add the Trackingplan plugin to the plugins block:
plugins {
    // ...
    id("com.trackingplan.client") version "2.2.0" apply false
}
  1. In the module-level build.gradle.kts of your app, apply the plugin and add the SDK:
plugins {
    // ...
    id("com.trackingplan.client")
}

dependencies {
    // ...
    implementation("com.trackingplan.client:sdk:3.1.1")
}

With Groovy (build.gradle), the lines are the same with Groovy syntax: id 'com.trackingplan.client' version '2.2.0' apply false in the project-level plugins, and id 'com.trackingplan.client' in the module-level plugins with implementation 'com.trackingplan.client:sdk:3.1.1' in its dependencies.

If your project still uses the legacy buildscript block, add classpath 'com.trackingplan.client:adapter:2.2.0' to its dependencies (with mavenCentral() among its repositories), and apply plugin: 'com.trackingplan.client' at the top of the module-level build.gradle.

  1. Start Trackingplan at the beginning of the onCreate() method of your Application class, before the SDK of any destination:
import android.app.Application;
import com.trackingplan.client.sdk.Trackingplan;

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Trackingplan.init("YOUR_TP_ID").start(this);
        // ... the rest of your setup, after Trackingplan
    }
}

If your app already has an Application class (the one android:name names on the <application> element of your AndroidManifest.xml), add the line to its onCreate(). If it has none, create one as above and register it in AndroidManifest.xml with <application android:name=".MyApplication" …>; Android does not run its onCreate() otherwise. Or start Trackingplan in the onCreate() of your main activity instead: it then misses whatever your app sends before that activity starts.

All set. Now check that Trackingplan is collecting data correctly.

You can also build Trackingplan for Android from the source code. To learn how, see our GitHub documentation.

Installing Android SDK in a Flutter project

Open the android directory inside your Flutter project, then:

  • In android/build.gradle (or android/settings.gradle, depending on your Flutter version), add the Trackingplan plugin as in step 2 above. With a legacy buildscript block, add classpath "com.trackingplan.client:adapter:2.2.0" to its dependencies.
  • In android/app/build.gradle, apply the plugin (id 'com.trackingplan.client' in plugins, or apply plugin: 'com.trackingplan.client') and add implementation 'com.trackingplan.client:sdk:3.1.1' to its dependencies.
  • Make sure minSdk is 24 or higher.

Finally, start Trackingplan in the onCreate() method of your Application class or, if your app has none, of MainActivity (android/app/src/main/kotlin):

import com.trackingplan.client.sdk.Trackingplan

Trackingplan.init("YOUR_TP_ID").start(this)

Installing Trackingplan in Ionic for Android platform

  1. Add the Trackingplan classpath dependency to the project-level android/build.gradle (the one at the root of the android folder, not the one inside android/app):
    classpath "com.trackingplan.client:adapter:2.2.0"
  2. Open the module-level Gradle file, android/app/build.gradle. In the dependencies block, add:
    implementation 'com.trackingplan.client:sdk:3.1.1'
  3. At the top level of that file, add:
    apply plugin: 'com.trackingplan.client'
  4. Start Trackingplan in your MainActivity.java file, located at android/app/src/main/java/MainActivity.java. Add an onCreate method inside the MainActivity class and start Trackingplan with your Trackingplan ID:
    import com.getcapacitor.BridgeActivity;
    import android.os.Bundle;
    import com.trackingplan.client.sdk.Trackingplan;
    
    public class MainActivity extends BridgeActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            // Start Trackingplan with your Trackingplan ID
            Trackingplan.init("YOUR_TP_ID").start(this);
        }
    }
    
  5. Set minSdkVersion = 24 or higher in android/variables.gradle.
  6. Run the commands:
    ionic build
    npx cap sync android
    npx cap run android
    

Android advanced options

Trackingplan.init("YOUR_TP_ID") returns a builder that takes these options before .start(this):

OptionDescriptionDefault
environment(value)Isolates the data of production and testing environments.PRODUCTION
sourceAlias(value)Tells your sources apart.android
tags(map)Tags for the data sent to Trackingplan, as a map of tag names and values.empty map
customDomains(map)Extends the list of monitored domains, as a map of domains and parser IDs. See custom domains.empty map
enableDebug()Prints debug information in the console.disabled
dryRun()Sends nothing to Trackingplan, so you can test the SDK. Requires enableDebug(): without it, start() throws an error.disabled
tracksEndPoint(value)Where Trackingplan sends your data. Set it only if your plan is not in the EU datacenter: contact us for its value.EU datacenter

For example:

Trackingplan.init("YOUR_TP_ID")
    .environment("development")
    .sourceAlias("Android app")
//  .tags(new HashMap<>(){{
//      put("tag1", "value1");
//  }})
//  .customDomains(new HashMap<>(){{
//      put("my.domain.com", "ssgtm");
//  }})
//  .enableDebug()
//  .dryRun()
    .start(this);

To change tags after Trackingplan has started, call Trackingplan.updateTags(newTags) with a map of the tags to add or replace.

Questions or problems along the way? Contact support.

Was this useful? Write to support@trackingplan.com