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

    @discardableResult
    open class func initialize(token apiToken: String,
                               trackAutomaticEvents: Bool,
                               flushInterval: Double = 60,
                               instanceName: String? = nil,
                               optOutTrackingByDefault: Bool = false,
                               useUniqueDistinctId: Bool = false,
                               superProperties: Properties? = nil,
                               serverURL: String? = nil) -> MixpanelInstance

    Parameters

    token

    your project token

    trackAutomaticEvents

    Whether or not to collect common mobile events

    flushInterval

    Optional. Interval to run background flushing

    instanceName

    Optional. The name you want to uniquely identify the Mixpanel Instance. It is useful when you want more than one Mixpanel instance under the same project token.

    optOutTrackingByDefault

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

    useUniqueDistinctId

    Optional. whether or not to use the unique device identifier as the distinct_id

    superProperties

    Optional. Super properties dictionary to register during initialization

    serverURL

    Optional. Mixpanel cluster URL

    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.

    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

    @discardableResult
    open class func initialize(token apiToken: String,
                               trackAutomaticEvents: Bool,
                               flushInterval: Double = 60,
                               instanceName: String? = nil,
                               optOutTrackingByDefault: Bool = false,
                               useUniqueDistinctId: Bool = false,
                               superProperties: Properties? = nil,
                               proxyServerConfig: ProxyServerConfig) -> MixpanelInstance

    Parameters

    token

    your project token

    trackAutomaticEvents

    Whether or not to collect common mobile events

    flushInterval

    Optional. Interval to run background flushing

    instanceName

    Optional. The name you want to uniquely identify the Mixpanel Instance. It is useful when you want more than one Mixpanel instance under the same project token.

    optOutTrackingByDefault

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

    useUniqueDistinctId

    Optional. whether or not to use the unique device identifier as the distinct_id

    superProperties

    Optional. Super properties dictionary to register during initialization

    proxyServerConfig

    Optional. Setup for proxy server.

    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.

  • 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