Analytics, iOS
  • 15 Aug 2023
  • 3 Minutes to read
  • Contributors
  • Dark
    Light

Analytics, iOS

  • Dark
    Light

Article summary

Authentication Analytics

see iOS Authentication Analytics

Tickets Analytics

The TMTicketsAnalyticsDelegate protocol contains a few simple methods for being informed of user behavior within the Tickets framework.

Page Views

When the user views a new page, that page is returned with appropriate metadata (including the Events, Tickets, or Module being viewed). see userDidView(page:metadata:)

Pages:

/// user-facing UI screen/page within Tickets SDK
public enum Page: String {
    /// purchased Events listing page ("My Events")
    case events
    
    /// Tickets listing page for a specific Event ("My Tickets")
    case eventTickets
    /// user scrolled down to view Modules on Tickets listing page
    case eventModules
    
    /// Ticket Barcode page
    case ticketBarcode
    /// Ticket Delivery method info (non-barcode)
    case ticketDelivery
    /// Ticket Details page ("Back of Ticket")
    case ticketDetails
                
    /// user has to complete 2FA/MFA to continue
    case mfaForTicketOperation
    /// user has to complete 2FA/MFA to continue
    case mfaForViewBarcode
    /// user has to complete 2FA/MFA to continue
    case mfaForWebpage

    /// event info banner (health check, tax info, etc)
    case eventInfoBanner
}

User Actions

When the user interacts with a native control component or module, that action is returned with appropriate metadata (including the Events, Tickets, or Module being interacted with). see userDidPerform(action:metadata:)

Actions

public enum Action: String {
    // single ticket
    /// user pressed Apple `Add To Wallet` button
    case addTicketToWalletButton

    /// user took a screenshot of the Barcode
    case barcodeScreenshot

    /// user pressed the Send Transfer button
    case transferSendButton
    /// user pressed the Cancel Transfer button
    case transferCancelButton
    
    /// user pressed the Edit Resale Posting button
    case postingEditButton
    /// user pressed the Cancel Resale Posting button
    case postingCancelButton

    
    // tickets page
    /// user pressed the More Info button on the Event Info banner, shown at the top of Tickets listing page
    case eventInfoBannerButton
    
    /// user pressed a button on a ``TMTicketsModule``
    case moduleActionButton
    
    
    // events page
    /// user did pull to refresh Events listing page
    case pullToRefreshEvents
    
    // generic
    /// user pressed the NavBar button (see: ``TMTickets/navBarButtonTitle``)
    case navbarButtonAction
}

Note that this these calls are for analytics only.

  • This is not where your code should handle the module action buttons. see TMTicketsModuleDelegate in iOS Custom Modules
  • This is not where your code should handle the navBar button. see TMTicketsOrderDelegate

Metadata

Depending on the page or action being returned, different types of metadata are included (related to Events, Tickets, and Modules).

Example metadata-parsing implementation:

/// optional delegate to be informed of User behavior
extension TicketsHelper: TMTicketsAnalyticsDelegate {
    
    /// user did view a page
    ///
    /// - Parameters:
    ///  - page: ``TMTickets/Analytics/Page`` (UI screen) being viewed by User
    ///  - metadata: any Event or Ticket ``TMTickets/Analytics/MetadataType`` associated with page
    func userDidView(page: TMTickets.Analytics.Page, metadata: TMTickets.Analytics.MetadataType) {
        print("userDidViewPage: \(page.rawValue)")

        // different Pages return different types of metadata
        switch metadata {
        case .events(let events):
            print(" - events: \(events.count)")
        case .event(let event):
            print(" - event: \(event.info.identifier)")
        case .eventTickets(let event, let tickets):
            print(" - event: \(event.info.identifier) tickets: \(tickets.count)")
        case .eventTicket(event: let event, let ticket):
            let ticketSummary = "\(ticket.sectionName ?? "_") \(ticket.rowName ?? "_") \(ticket.seatName ?? "_")"
            print(" - event: \(event.info.identifier) ticket: \(ticketSummary)")
        case .module(let event, let identifier):
            print(" - module: \(identifier) event: \(event.info.identifier)")
        case .moduleButton(let event, let module, let button):
            print(" - module: \(module.identifier) button: \(button.title)(\(button.callbackValue) event: \(event.info.identifier)")
        case .empty:
            print(" - empty")
        @unknown default:
            print(" - empty")
        }
    }
    
    /// user did perform an action
    ///
    /// - Parameters:
    ///  - action: ``TMTickets/Analytics/Action`` (button press) performed by User
    ///  - metadata: any Event or Ticket ``TMTickets/Analytics/MetadataType`` associated with action
    func userDidPerform(action: TMTickets.Analytics.Action, metadata: TMTickets.Analytics.MetadataType) {
        print("userDidPerformAction: \(action.rawValue)")
        
        // different Actions return different types of metadata
        switch metadata {
        case .events(let events):
            print(" - events: \(events.count)")
        case .event(let event):
            print(" - event: \(event.info.identifier)")
        case .eventTickets(let event, let tickets):
            print(" - event: \(event.info.identifier) tickets: \(tickets.count)")
        case .eventTicket(event: let event, let ticket):
            let ticketSummary = "\(ticket.sectionName ?? "_") \(ticket.rowName ?? "_") \(ticket.seatName ?? "_")"
            print(" - event: \(event.info.identifier) ticket: \(ticketSummary)")
        case .module(let event, let identifier):
            print(" - module: \(identifier) event: \(event.info.identifier)")
        case .moduleButton(let event, let module, let button):
            print(" - module: \(module.identifier) button: \(button.title)(\(button.callbackValue)) event: \(event.info.identifier)")
        case .empty:
            print(" - empty")
        @unknown default:
            print(" - empty")
        }
    }
}

Webviews

Many online operations, such as Transfer or Resale have been moved into webviews (internal webpages). Currently only a very limited amount of analytics are returned from these webpages to the Tickets framework.

In the future, more webpage analytics will be returned to the Tickets framework where it can then be shared with your application using the methods defined above.


Was this article helpful?