CleverTap GTM iOS Integration
Learn how to send iOS app events to CleverTap via GTM
Overview
Using Google Tag Manager for iOS, you can control which of your third-party vendors receive events and create tags specific to CleverTap.
Clevertap iOS SDK can be initialized and controlled by tags configured within Google Tag Manager. But, before using Google Tag Manager, ensure that you complete the initial Android SDK Setup.
Integration
The following are the steps to integrate CleverTap with GTM in your project:
-
To install the CleverTap iOS SDK, refer to the Install SDK section.
-
To associate your iOS app with your CleverTap account, you must add your CleverTap credentials in the
Info.plist
file in your application. To do so:a. Create a key called
CleverTapAccountID
of type string.
b. Create a key calledCleverTapToken
of type string.
c. Insert the Account ID and Account Token values from your CleverTap account by navigating to the Settings page. Here, the Account ID is equivalent to the Project ID. -
Initialize the SDK.
-
Objective-C
a. Import
CleverTap.h
to yourAppDelegate.h
file.
b. ImportCleverTap.h
into every class where you plan to record user events. For instance, in the application code shown below, we record user events in theViewController
class by importingCleverTap.h
into the ViewController.h file.
(BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
[CleverTap autoIntegrate];
...
}
-
Swift
a. Import
CleverTapSDK
to yourAppDelegate.swift
file.
b. Add [CleverTap autoIntegrate] within theapplication:didfinishlaunchingwithoptions:
method of yourAppDelegate.m
file. This creates an instance of the CleverTap class used to track app launches, receive in-app notifications, and enable deep-link tracking.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject:AnyObject]?) -> Bool {
...
CleverTap.autoIntegrate()
...
}
- To enable location tracking, and network information, you must call the following method in your app build:
ObjC: [[CleverTap sharedInstance] enableDeviceNetworkInfoReporting:YES];
clevSwift: CleverTap.sharedInstance().enableDeviceNetworkInfoReporting(true)
Updated about 1 year ago