Mobile: Send Custom Events to Appcues (technical)

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


Strengthen your audience segments by tracking your users's behaviors and actions. Appcues already sends

Recommended events

See the  Events Overview for recommendations.


Let's consider an auction app that wishes to show a message of congratulations after a user creates their first auction.

Adding Events

  1. Add import Appcues to your ViewController 
  2.  Create an event with the function AppcuesEvent(name: String)
  3. Add the event to an array. Add more events to this array if several events should be sent to Appcues.
  4. Call the track function whenever an event should be sent to Appcues. The time at which the event occurred, as well as information about the user who experienced the event, is automatically recorded, so don't worry about putting this in yourself.


// Add the Appcues module to your ViewController
import Appcues

class ViewController: UIViewController {

  func track(event: Event) {
    // Add event attributes
    let createdAuctionEvent = AppcuesEvent(name: "Created auction")
    // Create an Appcues event
    let events = [createdAuctionEvent]

    // Send the event to Appcues
    Appcues.shared.track(events: events)



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

@implementation ViewController

- (void)trackEvent: (Event *)event {
  // Add event attributes
  AppcuesEvent *createdAuctionEvent = 
    [[AppcuesEvent alloc] initWithName:@"Created auction" attributes:nil];
  // Create an Appcues event
  NSArray *events = [[NSArray alloc] initWithObjects:createdAuctionEvent, nil];

  // Send the event to Appcues
  [Appcues trackWithEvents:events];


Ensure  Appcues.identify(user: AppcuesUser) or Appcues.anonymous() has been called before tracking events.

A user id, whether identified or anonymous, is required to record event data, so make sure any calls to  track come after a call to identify or anonymous.

Don't put too much detail into event names.

You want to be able to group similar events by name, so rather than sending in the name Added item ID=12345 to shopping cart", send in the item_id as an attribute


let attributes = ["item_id" : "12345"]
let createdAuctionEvent = AppcuesEvent(name: "Created auction", attributes: attributes)


NSDictionary *attributes = @{ @"item_id" : "12345" };
AppcuesEvent *createdAuctionEvent = 
  [[AppcuesEvent alloc] initWithName:@"Created auction" attributes:attributes];

Targeting based on event attribute values may be added in a future version of Appcues.

Still need help? Contact Us Contact Us