Registering for Analytics

Initializing Analytics

To have VenueNext events reported to your preferred analytics tool, first create an object that conforms to the VNAnalyticsProtocol. The protocol contains several functions that are called when events are triggered in the SDK.

Adding Your VNAnalyticsProtocol

Once you’ve created your VNAnalyticsProtocol, pass an instance of it to the VenueNextWeb object via the following API:

VenueNextWeb.shared.configureAnalytics(self)

or

import UIKit
import VNWebSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, VNAnalyticsProtocol {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch

        // Use this method signature to initialize for production environment
        // Deprecated in v2.0.9
        // VenueNextWeb.shared.initialize("<YOUR-ORDERNEXT_INSTANCE>")
        // Introduced in v2.0.9
        // This would point to yourordernextinstance.ordernext.com
        VenueNextWeb.shared.initialize("<ORGANIZATION_NAME>", instance: "<YOUR_ORDERNEXT_INSTANCE>")

        // Use this method signature to initialize for an environment other than production
        // Deprecated in v2.0.9
        // VenueNextWeb.shared.initialize("<YOUR-ORDERNEXT_INSTANCE>")
        // Introduced in v2.0.9
        // This would point to yourordernextinstance.ordernext.com
        VenueNextWeb.shared.initialize("<ORGANIZATION_NAME>", instance: "<YOUR_ORDERNEXT_INSTANCE>", env: "<ENV>")
        VenueNextWeb.shared.configureAnalytics(self)

        window = UIWindow(frame: UIScreen.main.bounds)

        window?.rootViewController = UINavigationController(rootViewController: DemoTableViewController())
        window?.makeKeyAndVisible()

        return true
    }
}

Tracking by Method Signature

func trackUserId(_ id: String)
  • Triggered each time the User information is fetched via the webview, or when a User is created.
  • Note: If you want to ensure this event is captured, make sure to add your VNAnalyticsInterface before presenting a webview page.
func trackUserAffiliations(_ affiliations: [String])
  • Triggered when a User’s affiliations are fetched via the webview, such as season ticket holder member tiers.
  • Currently reported when viewing the Wallet page or when attempting to purchase an experience in the marketplace.
func trackRvcSelection(
  itemId: String,
  itemName: String,
  itemCategory: String
)
  • Triggered when a user taps on a Revenue Center (RvC).
  • This will work for F&B, Merch, & Experiences
func trackMenuItemSelection(
  itemId: String,
  itemName: String,
  itemCategory: String,
  variant: String,
  price: Int
)
  • Triggered when a user taps on an item being displayed in a Menu
  • For Food and Beverage menus, this will provide the base price of an item
  • For Experience menus, prices may vary based on which Event the user has selected:
    • If the user has selected an event, the price of the item relative to that event will be provided
    • If the user has not selected an event, the price of the item relative to the next event where the Experience is available will be provided
func trackBeginCheckout()
  • Triggered when a user enters the Checkout screen
func trackAddItemToCart(
  itemId: String,
  itemName: String,
  itemCategory: String,
  variant: String,
  price: Int,
  quantity: Int
)
  • Triggered when a user adds an item to their Cart
  • For Food and Beverage menus, this will provide the base price of an item
  • For Experience menus, currently this event will not be triggered - this will be updated in a future release
func trackRemoveItemFromCart(
  itemId: String,
  itemName: String,
  itemCategory: String,
  variant: String,
  price: Int,
  quantity: Int
)
  • Triggered when a user removes an individual item from their cart at Checkout
// Introduced in 2.1.0
func trackCompletedPurchase(
  orderId: String,
  quantity: Int,
  discount: Double,
  tips: Double,
  tax: Double,
  total: Double,
  paymentTypes: String,
  name: String?,
  email: String?
)
// Deprecated in 2.1.0
func trackCompletedPurchase(
  orderId: String,
  quantity: Int,
  discount: Double,
  tips: Double,
  tax: Double,
  total: Double,
  paymentTypes: String
)
  • Triggered whenever a user completes a purchase, regardless of the order state.
func trackCheckoutProgress(orderId: String, state: String)
  • Triggered once when the user completes a purchase at Checkout.
  • Triggered every time the order state changes while the user is viewing the Receipt

Enabling/Disabling Analytics

Analytics are enabled by default. Meaning if not explicitly disabled, analytics events will be sent to a class conforming to the VNAnalyticsProtocol once it has been configured via VenueNextWeb.shared.configureAnalytics(myAnalyticsProtocol). However, analytics can be disabled/enabled with the use of the VenueNextWeb.shared.setAnalyticsEnabled(_ enabled: Bool) method:

    /**
     Sets a flag that dictates whether or not analytics are enabled. If disabled, no analytics events should be triggered.
     
     - Parameters:
        - enabled:`true` if analytics events should be triggered. `false` otherwise.
     */
    public func setAnalyticsEnabled(_ enabled: Bool)

If disabled via this method, analytic events will not be triggered, even if VenueNextWeb.shared.configureAnalytics(myAnalyticsProtocol) has been called. Therefore, it is safe to always configure the protocol if desired, even if analytics are disabled. If .setAnaltycsEnabled(true) is called later, analytic events will again be sent to the configured analytics protocol without the need to call .configureAnalytis(myAnalyticsProtocol) again.

This setting will also be persisted across app sessions. This means if .setAnalytics(false) has been called previously, analytics will continue to be disabled, even if the app is hard-closed and opened again later, until .setAnalyticsEnabled(true) is called, or the app is deleted, thus clearing the app storage on the device.

The current status of wether VenueNext analytics are enabled or disabled can also be checked if desired via VenueNextWeb.shared.checkAnalyticsEnabledStatus():

    /**
     `true` if analytics events should be triggered. `false` otherwise. This flag will persist across app sessions.
     
     Defaults to `true` if never set. This means analytics are enabled by default.
     */
    public func checkAnalyticsEnabledStatus() -> Bool

Reminder: Analytics are enabled by default and must explicitly be disabled if desired.

Updated: