Last modified May 25, 2020 by Shelly Wolfe

How do I log advertising and vendor IDs?

As of December 2015, it is possible to log advertising and vendor identifiers. This article explains how to configure the iOS and Android SDKs to do so.

iOS

As of Swrve iOS SDK version 7.0.0, SWRVE_LOG_IDFA and SWRVE_LOG_IDFV have been deprecated. For version 7.0.0 and above, use the following methods.

To log IDFA (Identifier for Advertisers), use the new public API [SwrveSDK idfa:] to set the IDFA after the user has given their permission. For example:

import SwrveSDK

if (@available(iOS 14, tvOS 14, *)) {
  [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {

    if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
         
         NSString *idfa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
         [SwrveSDK idfa:idfa];
    }

  }];
}

To log IDFV (Identifier for Vendors), use the new config value config.autoCollectIDFV = true to auto-collect the IDFV.

For older versions of the iOS SDK

To log IDFA, add a constant called SWRVE_LOG_IDFA to the preprocessor macros under App Target > Build Settings > Preprocessing > Preprocessor Macros. This logs a user property called swrve.IDFA to the Swrve system.

As of iOS 14, Apple requires user permission to collect the IDFA. If a user gives permission and SWRVE_LOG_IDFA is enabled, the SDK will continue to automatically collect the IDFA and send with device info updates.

To log IDFV, add a constant called SWRVE_LOG_IDFV to the preprocessor macros under App Target > Build Settings > Preprocessing > Preprocessor Macros. This logs a user property called swrve.IDFV to the Swrve system.

Android

To log GAID (Google Advertising ID), call method SwrveConfig.setGAIDLoggingEnabled(true) before creating the SDK instance. This logs a user property called swrve.GAID to the Swrve system.

To log the Google Android ID, call method SwrveConfig.setAndroidIdLoggingEnabled(true) before creating the SDK instance. This logs a user property called swrve.android_id to the Swrve system.