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.plistfile in your application. To do so:a. Create a key called
CleverTapAccountIDof type string.
b. Create a key calledCleverTapTokenof 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.hto yourAppDelegate.hfile.
b. ImportCleverTap.hinto every class where you plan to record user events. For instance, in the application code shown below, we record user events in theViewControllerclass by importingCleverTap.hinto the ViewController.h file.
(BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
[CleverTap autoIntegrate];
...
}
-
Swift
a. Import
CleverTapSDKto yourAppDelegate.swiftfile.
b. Add [CleverTap autoIntegrate] within theapplication:didfinishlaunchingwithoptions:method of yourAppDelegate.mfile. 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 almost 2 years ago
