Mixpanel

open class Mixpanel

The primary class for integrating Mixpanel with your app.

  • Initializes an instance of the API with the given project token.

    Returns a new Mixpanel instance API object. This allows you to create more than one instance of the API object, which is convenient if you’d like to send data to more than one Mixpanel project from a single app.

    Important

    If you have more than one Mixpanel instance, it is beneficial to initialize the instances with an instanceName. Then they can be reached by calling getInstance with name.

    Declaration

    Swift

    open class func initialize(token apiToken: String,
                               launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil,
                               flushInterval: Double = 60,
                               instanceName: String = UUID().uuidString,
                               automaticPushTracking: Bool = true,
                               optOutTrackingByDefault: Bool = false) -> MixpanelInstance

    Parameters

    token

    your project token

    launchOptions

    Optional. App delegate launchOptions

    flushInterval

    Optional. Interval to run background flushing

    instanceName

    Optional. The name you want to call this instance

    optOutTrackingByDefault

    Optional. Whether or not to be opted out from tracking by default

    Return Value

    returns a mixpanel instance if needed to keep throughout the project. You can always get the instance by calling getInstance(name)

  • Initializes an instance of the API with the given project token (MAC OS ONLY).

    Returns a new Mixpanel instance API object. This allows you to create more than one instance of the API object, which is convenient if you’d like to send data to more than one Mixpanel project from a single app.

    Important

    If you have more than one Mixpanel instance, it is beneficial to initialize the instances with an instanceName. Then they can be reached by calling getInstance with name.

  • Gets the mixpanel instance with the given name

    Declaration

    Swift

    open class func getInstance(name: String) -> MixpanelInstance?

    Parameters

    name

    the instance name

    Return Value

    returns the mixpanel instance

  • Returns the main instance that was initialized.

    If not specified explicitly, the main instance is always the last instance added

    Declaration

    Swift

    open class func mainInstance() -> MixpanelInstance

    Return Value

    returns the main Mixpanel instance

  • Sets the main instance based on the instance name

    Declaration

    Swift

    open class func setMainInstance(name: String)

    Parameters

    name

    the instance name

  • Removes an unneeded Mixpanel instance based on its name

    Declaration

    Swift

    open class func removeInstance(name: String)

    Parameters

    name

    the instance name