Mobile: Identify Users in your App (technical)

If you haven't already installed, initialized and identified screens for Appcues Mobile in your app, make sure to go here first. 

Recommended Attributes

See the User Properties Overview for recommendations.

Appcues sends some default User Information

Once a user is identified, the sdk automatically sends some user information to Appcues. The information being sent are:

  • OS version: the iOS version that the device or simulator is running on. For instance, "12.1".
  • App version: the version of your app. For instance, "2.1.0".
  • Build version: the build version of your app. For instance, "1".
  • Device type: "iPhone", "iPad" or "Pod touch"
  • Day of week: the day of where the device or simulator is. For instance, "Monday", "Tuesday", "Wednesday" etc.
  • Device language: the local device or simulator language. For instance, "en" for English .
  • Simulator: true if your app is running on a simulator, otherwise false.
  • Appcues version: the Appcues Mobile sdk version your app is running. For instance, "0.3.0".

Using Appcues for Identified Users

Make sure to make this call before any Appcues.shared.showEligibleFlowsOn(viewController:named:) call is made. 

  1. Add import Appcues to your ViewController 
  2. Create a user with the function AppcuesUser(id: String)  Each of your users must have a unique id associated with them. You can define this in any way you'd like (i.e. email, unique identifier code, etc.). If the user id is the same as the user id on web, you could target the same user. 
  3. Optional: Add user attributes to your user. These are any user attributes you'd like to target on like first name, last name, position, age, etc. To send in attributes, use the function  AppcuesUser(id: String, attributes: [String : Any]?)
  4. Call Appcues.shared.identify(user: AppcuesUser)

Swift

// Add the Appcues module to your ViewController
import Appcues

class ViewController: UIViewController {
  
  func identify(user: User) { 

    // Add user attributes
    let userAttributes = ["name": user.name, "email": user.email]
  
    // Create an Appcues user
    let user = AppcuesUser(id: user.id, attributes: userAttributes)

    // Identify the user
    Appcues.shared.identify(user: user)
  }
}

Objective C

// Add the Appcues module to your ViewController
@import Appcues;

@implementation ViewController

- (void)identifyUser: (User *)user {
  
  // Add user attributes
  NSDictionary *userAttributes = @{ @"name" : user.id, @"email" : user.email };

  // Create an Appcues user
  AppcuesUser *user = [[AppcuesEvent alloc] initWithId:user.id attributes:userAttributes];
		
  // Identify the user
  [Appcues.shared identifyWithUser:user]
}

@end

Using Appcues for Anonymous Users

Do not add this call if you already have Appcues.shared.identify(user: AppcuesUser) implemented.

Typically Appcues flows are shown to users who are logged-in to your site, though there may be occasions when you'd like to target flows to anonymous visitors. 

You can use Appcues without user information for a public site or unidentified user in your app. To display messages based off of some behavior, you'll need to call Appcues.anonymous() in your installation.

  1. Add import Appcues to your ViewController 
  2. Call Appcues.shared.anonymous()

Swift

// Add the Appcues module to your ViewController
import Appcues  

class ViewController: UIViewController { 	 	
   
  func identifyUser() {  
    // Identify an anonymous user			
    Appcues.shared.anonymous()
  }  

}

Objective C

// Add the Appcues module to your ViewController
@import Appcues;  

@implementation ViewController  

- (void)identifyUser { 	
  // Identify an anonymous user			
  [Appcues.shared anonymous];
}

@end

Next Step

Once you have Appcues Mobile installed, initialized, screens identified and users identified in your app, you are good to go to add flows (tooltips, modals) to your app! There are two optional steps: 

Still need help? Contact Us Contact Us