--- title: "Set up Analytics" slug: "set-up-analytics" updated: 2026-06-23T20:32:04Z published: 2026-06-23T20:32:04Z canonical: "ignite.ticketmaster.com/set-up-analytics" --- > ## Documentation Index > Fetch the complete documentation index at: https://ignite.ticketmaster.com/llms.txt > Use this file to discover all available pages before exploring further. # Set up Analytics ## PrePurchase Analytics: Analytics can be triggered to your own analytics portal by using the callbacks provided by SDK. Every page view and didShare action will trigger a callback that you can use to record the analytics data. Initialization Method: ```swift // For PrePurchase to load with initial page as home/search/attraction/venue  TMPrePurchaseViewController(initialPage: TicketmasterPrePurchase.TMPrePurchaseViewController.PrePurchasePage, marketDomain: TicketmasterFoundation.MarketDomain = .US, // Set valid marketDomain based on your region - US or AU or UK etc marketLocation: TicketmasterFoundation.MarketLocation?, queryParameters: [String : String]?, enclosingEnvironment: TicketmasterPrePurchase.TMPrePurchaseViewController.EnclosingEnvironment, allowJavaScriptToBringUpKeyboard: Bool, internalTestingKeys: [String : Any]? = nil) // For PrePurchase to load attraction TMPrePurchaseViewController.attractionDetailsViewController(attractionIdentifier: String, marketDomain: MarketDomain = .US, enclosingEnvironment: EnclosingEnvironment) // For PrePurchase to load venue TMPrePurchaseViewController.venueDetailsViewController(venueIdentifier: String, marketDomain: MarketDomain = .US, enclosingEnvironment: EnclosingEnvironment) ``` Initialization Example: ```swift // For PrePurchase to load with initial page as home/search/attraction/venue  let prePurchaseVC = TMPrePurchaseViewController(initialPage: page, marketDomain: forcedMarketDomain, // Set valid marketDomain based on your region - US or AU or UK etc marketLocation: homepageMarketLocation, // if showing homepage (Should be market domain specific market location) queryParameters: nil, enclosingEnvironment: .navigationController, allowJavaScriptToBringUpKeyboard: false) // For PrePurchase to load attraction let viewController = TMPrePurchaseViewController.attractionDetailsViewController(attractionIdentifier: "1646704", marketDomain: .US, enclosingEnvironment:.tabBarController) // For PrePurchase to load venue let viewController = TMPrePurchaseViewController.venueDetailsViewController(venueIdentifier: "82789", marketDomain: .US, enclosingEnvironment:.tabBarController) /// Setting analytics delegate (optional) viewController.analyticsDelegate = self /// Setting navigation delegate viewController.navigationDelegate = self /// Setting location delegate viewController.locationDelegate = self ``` Analytics Delegate Methods: ```swift public protocol TMPrePurchaseAnalyticsDelegate: AnyObject { // MARK: User Behavior Analytics /// user has just shared this ADP/VDP page func prePurchaseViewController(_ viewController: TMPrePurchaseViewController, didShare pageTitle: String, and pageURL: URL, to activityType: UIActivity.ActivityType) // MARK: UAL Webpage Analytics /// PrePurchase webview has fired a pageView func prePurchaseViewController(_ viewController: TMPrePurchaseViewController, didFirePageView pageView: UALPageView) } ``` Navigation Delegate Methods: ```swift public protocol TMPrePurchaseNavigationDelegate: AnyObject { /// PrePurchase needs to open an EDP (Event Details Page) to possibly make a purchase. /// /// - Note: Your code needs to initialize and display the Purchase SDK here /// /// - Parameters: /// - eventIdentifier: Event identifier func prePurchaseViewController(_ viewController: TMPrePurchaseViewController, navigateToEventDetailsPageWithIdentifier eventIdentifier: String) } ``` Location Delegate Methods: ```swift public protocol TMPrePurchaseLocationDelegate: AnyObject { // Called when user uses web UI to change the current market func prePurchaseViewController(_ viewController: TMPrePurchaseViewController, didChangeLocationTo location: MarketLocation) // Called when the user taps Use Current Location. // The integrating app, once receiving this callback, is expected to ask for device location, possibly triggering permission prompt. //Respond with either of the two public functions, depending on the outcome. func prePurchaseViewControllerDidRequestCurrentLocation(_ viewController: TMPrePurchaseViewController) } ``` To get analytics from PrePurchase SDK create your own implementation of TMPrePurchaseWebAnalyticsListener and TMPrePurchaseUserAnalyticsListener, and add these to TMPrePurchaseFragmentFactory when initializing PrePurchase. ```custom private val integratorFactory: TMPrePurchaseFragmentFactory by lazy { TMPrePurchaseFragmentFactory( tmPrePurchaseNavigationListener = NavigationListener(), tmPrePurchaseShareListener = ShareListener(), tmPrePurchaseUserAnalyticsListener = UserAnalyticsListener(), tmPrePurchaseWebAnalyticsListener = WebAnalyticsListener() ) } ``` TMPrePurchaseUserAnalyticsListener will notify the integrating app when an Event has been selected, and when Sharing has been selected on ADP/VDP ```custom public interface TMPrePurchaseUserAnalyticsListener : Serializable { /** * This method is called when the user select an event available on ADP/VDP * @param event The event for which the ticket selection screen is opened */ public fun onEDPSelectionStarted(event: DiscoveryEvent) /** * This method is called when the user selects a menu item * @param event The Artist/Venue on which the user selected the menu item * @param menuItemSelected The menu item that was selected */ public fun onMenuItemSelected( event: DiscoveryAbstractEntity, menuItemSelected: TMPrePurchaseMenuItem ) } ``` TMPrePurchaseWebAnalyticsListener will notify the integrating app of the current state of the page being loaded, and the analytics for the current page being viewed. ```custom public interface TMPrePurchaseWebAnalyticsListener : Serializable { /** * This method is called when a webpage is loading * @param url The url that is been loaded */ public fun onLoadingPage(url: URL) /** * A warning that the page is taking so long to load, that the native loading was dismissed as a precaution. * @param url The url that is taking long to load * @param duration */ public fun onPageLoadProgressBarTimeout(url: URL, duration: Long) /** * This method is called when an error occurs while loading the page * @param url The url at which the error occurred * @param error The exception */ public fun errorOnPageLoad(url: URL, error: Exception) /** * This method is called when the page is loaded * @param url The url that has loaded * @param duration The time taken for loading the url */ public fun onPageLoadComplete(url: URL, duration: Long) // TODO needs further clarification /** * This method is called when an error occurs on a webpage * @param url The url where the error occurred * @param error The exception */ public fun errorOnWebpage(url: URL, error: Exception) /** * This method is called when a user visits a webpage * @param */ public fun onWebpageReportedUALPageView(pageView: UALPageView) /** * This can be ignored * Only Available for Ticketmaster App */ public fun onWebpageReportedUALUserAction(action: UALUserAction) } ``` TMPrePurchaseNavigationListener will notify the integrating app of the desired Navigation on ADP/VDP ```custom public interface TMPrePurchaseNavigationListener : Serializable { /** *User has selected an Event from either ADP/VDP * @param event selected event for current attraction/venue * @param abstractEntity current attraction/venue */ public fun openEventDetailsPage(abstractEntity: DiscoveryAbstractEntity?, event: DiscoveryEvent) /* * Current URL is not supported * Integrating app decides how to proceed */ public fun openURLNotSupported(url: String) /* * Toolbar Action Icon Pressed * Integrating app decides how to proceed * Ex: Pop back-stack or replace current fragment */ public fun onHamburgerMenuPressed() /* * Current Location Requested by user * Obtain necessary permissions * return location as string */ public fun onDidRequestCurrentLocation( globalMarketDomain: TMMarketDomain?, completion: (String) -> Unit ) /* * Current Location Updated by user */ public fun onDidUpdateCurrentLocation( globalMarketDomain: TMMarketDomain?, location: Location ) } ``` TMPrePurchaseSharingListener will share the displayed attraction/venue with your customized message. ```custom public interface TMPrePurchaseSharingListener : Serializable { /** * Set a customized sharing message based on the Artist or Venue being shared. * @param abstractEntity The Artist or Venue being shared * @return returns a customized sharing message set by integrating * app */ public fun getShareTextForArtistOrVenue(abstractEntity: DiscoveryAbstractEntity): String } ``` ## Purchase Analytics: Provides callbacks for user and transactional analytics. Based on your needs, handle the callbacks to report to your analytics dashboards. There are 2 delegate methods for purchase Analytics: TMPurchaseUserAnalyticsDelegate and TMPurchaseWebAnalyticsDelegate methods Initialization Methods: ```swift TMPurchaseNavigationController.eventDetailsNavigationController(eventIdentifier: String, marketDomain: MarketDomain = .US) ``` Initialization Example: ```swift let viewController = TMPurchaseNavigationController.eventDetailsNavigationController(eventIdentifier:"1234567", marketDomain: MarketDomain = .US) ``` Setting Analytics delegates: ```swift viewController.userAnalyticsDelegate = self viewController.webAnalyticsDelegate = self ``` Setting other delegates: ```swift viewController.sharingDelegate = self viewController.navigationDelegate = self ``` User Analytics delegates: ```swift /// The user analytics delegate of a `TMPurchaseNavigationController` /// /// Set an object as the user analytics delegate if your application is interested in knowing about the actions a user takes. public protocol TMPurchaseUserAnalyticsDelegate: AnyObject { /// Tells the delegate that the ticket selection portion of the purchase process began. func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, didBeginTicketSelectionFor event: DiscoveryEvent) /// Tells the delegate that the ticket selection portion of the purchase process ended. func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, didEndTicketSelectionFor event: DiscoveryEvent, because reason: TMEndTicketSelectionReason) /// Tells the delegate that the checkout portion of the purchase process began. func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, didBeginCheckoutFor event: DiscoveryEvent) /// Tells the delegate that the checkout portion of the purchase process ended. func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, didEndCheckoutFor event: DiscoveryEvent, because reason: TMEndCheckoutReason) /// Tells the delegate that the user made a purchase and is currently viewing the Order Confirmation page. /// - Note: `purchaseNavigationController(:didMakePurchaseForEvent)` is immediately called upon the purchase being completed, while the user is still viewing the Order Confirmation page. /// Once the user is finished viewing their Order Confirmation, the user presses the `Done` button on the navigation bar and `purchaseNavigationController(:didEndCheckoutForEvent:)` is called. /// If you want to update your UI (moving the user to the Orders Listing page, for example), wait for `purchaseNavigationControllerDidFinish()` to be called. func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, didMakePurchaseFor event: DiscoveryEvent, order: TMPurchaseOrder) /// Tells the delegate that the user pressed a button on the navigation header bar func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, didPressNavBarButtonFor event: DiscoveryEvent, button: TMPurchaseNavBarButton) /// Tells the delegate that the user shared a link to this event func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, didShare event: DiscoveryEvent, activityType: UIActivity.ActivityType) /// Tells the delegate that the user navigated to a sub-page with the EDP or Cart func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, didViewSubPageFor event: DiscoveryEvent, subPage: TMPurchaseSubPage) /// Tells the delegate that the user has interacted with an UI component, resulting in a decision func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, didMakeDecisionFor event: DiscoveryEvent, component: TMPurchaseComponent, decision: TMPurchaseDecision) ``` Web Analytics Delegates: ```swift /// The detailed anayltics delegate of a `TMPurchaseNavigationController`. /// /// This protocol can be used for information about server behavior while inside an instance of `TMPurchaseNavigationController`. public protocol TMPurchaseWebAnalyticsDelegate: AnyObject { // MARK: PageLoad Performance Callbacks /// Usually some kind of HTTP error loading webpage (a timeout?) func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, pageLoadDidErrorFor url: URL, error: NSError) /// an Error was explictly sent by Ticketmaster webpage via Javascript func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, webPageDidErrorFor url: URL, errorString: String) // MARK: UAL Callbacks /// internal pageView analytrics func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, webPageDidReportUALPageView pageView: UALPageView) /// internal commerceEvent analytics func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, webPageDidReportUALCommerceEvent commerceEvent: UALCommerceEvent) } ``` Sharing Delegates: ```swift /// The sharing delegate of a `TMPurchaseNavigationController`. /// This protocol can be used to customize the message included in the social sharing feature by providing a new message to replace the default one used by the Purchase SDK. /// Default Message: eventTitle + " " + eventDate /// - Note: If the delegate is not set or implemented, the default sharing message will be used. public protocol TMPurchaseSharingDelegate: AnyObject { /// Set a customized sharing message based on the Event being shared. /// Integrating App's Task: use the provided Event to create a customized social sharing message func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, sharingMessageFor event: DiscoveryEvent, completion: @escaping (_ sharingMessage: String) -> Void) } ``` Navigation Delegates: ```swift /// The navigation delegate of a `TMPurchaseNavigationController` /// Set an object as the navigation Delegate if your application is interested in knowing when the user navigates out of the `TMPurchaseNavigationController` public protocol TMPurchaseNavigationDelegate: AnyObject { /// Tells the delegate that the Purchase EDP could not be loaded due to an error func purchaseNavigationController(_ purchaseNavigationController: TMPurchaseNavigationController, didFailToLoadWith error: Error) /// Tells the delegate that the user dismissed `purchaseNavigationController`. /// - Note: This method will be called exactly once, at the end of a `TMPurchaseNavigationController`'s lifetime because the user has completed or aborted purchase. /// - Important: Instances of `TMPurchaseNavigationController` attempt to dismiss themselves automatically by default. This behavior can be disabled by `TMPurchase.dismissUponCompletion`. func purchaseNavigationControllerDidFinish(_ purchaseNavigationController: TMPurchaseNavigationController) } ``` To get analytics from Purchase SDK create your own implementation of TMPurchaseWebAnalyticsListener and TMPurchaseUserAnalyticsListener, and add these to TMPurchaseFragmentFactory when initializing Purchase. ```custom val factory = TMPurchaseFragmentFactory( tmPurchaseNavigationListener = NavigationListener(), tmPurchaseShareListener = ShareListener(), tmPurchaseUserAnalyticsListener = UserAnalyticsListener(), tmPurchaseWebAnalyticsListener = WebAnalyticsListener(), oAuthListener = oAuthListener ) ``` TMPurchaseNavigationListener ```custom /** * This listener will notify you the user navigation */ public interface TMPurchaseNavigationListener { /** * This method is called when the Purchase event details page could not be loaded due to an error * @param error The exception that occurred while loading the event details page */ public fun errorOnEventDetailsPage(error: Exception) /** * This method will be called when the user has completed or aborted purchase */ public fun onCheckoutClosed() public fun onActionItemClicked(attraction: DiscoveryAbstractEntity?) } ``` TMPurchaseSharingListener ```custom /** * This listener can be used to customize the message included in the social sharing feature by * providing a new message to replace the default one used by the Marketplace SDK. * Default Message: eventTitle + " " + eventDate */ public interface TMPurchaseSharingListener { /** * Set a customized sharing message based on the Event being shared. * @param event The Event being shared * @return returns a customized sharing message */ public fun getShareTextForEvent(event: DiscoveryEvent): String } ``` TMPurchaseUserAnalyticsListener ```custom /** * This listener notifies you about the user actions */ public interface TMPurchaseUserAnalyticsListener { /** * This method is called when the user opens ticket selection screen * @param event The event for which the ticket selection screen is opened */ public fun onTicketSelectionStarted(event: DiscoveryEvent) /** * This method is called when the user has finished the ticket selection process * @param event The event for which the ticket selection screen is complete * @param reason The reason ticket selection ended */ public fun onTicketSelectionFinished(event: DiscoveryEvent, reason: TMTicketSelectionEndReason) /** * This method is called when the checkout process has started * @param event The event for which the checkout process has started */ public fun onCheckoutStarted(event: DiscoveryEvent) /** * This method is called when the checkout process is finished * @param event The event for which the checkout process has finished * @param reason The reason checkout process finished */ public fun onCheckoutFinished(event: DiscoveryEvent, reason: TMCheckoutEndReason) /** * This method is called when the user made a purchase and is currently viewing the Order Confirmation page. * @param event The event which the user purchased * @param order The order for the purchase */ public fun onTicketPurchased(event: DiscoveryEvent, order: TMPurchaseOrder) /** * This method is called when the user selects a menu item * @param event The event on which the user selected the menu item * @param menuItemSelected The menu item that was selected */ public fun onMenuItemSelected(event: DiscoveryEvent, menuItemSelected: TMPurchaseMenuItem) /** * This method is called when the user shared a link to this event */ public fun onShare(event: DiscoveryEvent) /** * This method is called when the user navigated to a sub-page with the EDP or Cart * @param event The event on which the user is opening a subpage * @param subPage which sub-page with the EDP or Cart page has been viewed */ public fun onSubPageOpened(event: DiscoveryEvent, subPage: TMPurchaseSubPage) } ``` TMPurchaseWebAnalyticsListener ```custom /** * This listener informs you with the server interaction */ public interface TMPurchaseWebAnalyticsListener { /** * This method is called when an error occurs while loading the page * @param url The url at which the error occurred * @param error The exception */ public fun errorOnPageLoad(url: URL, error: Exception) // TODO needs further clarification /** * This method is called when an error occurs on a webpage * @param url The url where the error occurred * @param error The exception */ public fun errorOnWebpage(url: URL, error: Exception) /** * This method is called when a user visits a webpage * @param */ public fun onWebpageReportedUALPageView(pageView: UALPageView) /** * This method is called when a user performs an action, like a button click * @param */ public fun onWebpageReportedUALUserAction(action: UALUserAction) /** * This method is called when a user adds ticket to cart or purchases the ticket * @param */ public fun onWebpageReportedUALCommerceEvent(commerceEvent: UALCommerceEvent) } ```