Mobile: Sending Mobile Events Guide (technical)

This article is intended for developers implementing Appcues. See the Events Overview for a higher level explanation.

Events

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

Recommended events

See the  Events Overview for recommendations.

Example

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

Adding Events

If you haven't installed Appcues, adding Events is covered in the  Mobile Installation Guide (technical) and you should start there. 

1. First import the Appcues module.

Swift

import Appcues

Objective-C

@import Appcues;

2. Create an event object.

Swift

let createdAuctionEvent = AppcuesEvent(name: "Created auction")

Objective-C

AppcuesEvent *createdAuctionEvent = [[AppcuesEvent alloc] initWithName:@"Created auction" attributes:nil];

3. Add the event to an array. Add more events to this array if several events should be sent to Appcues.

Swift

let events = [createdAuctionEvent]

Objective-C

NSArray *events = [[NSArray alloc] initWithObjects:createdAuctionEvent, nil];

4. Call the track function whenever an event should be sent to Appcues.

Swift

Appcues.track(events: events)

Objective-C

 [Appcues trackWithEvents:events];

5. This is an example of how this event could look like in Xcode

Swift

Objective-C

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.

Tips

Ensure  Appcues.identify() 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

Swift

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

Objective-C:

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