All Projects → mixpanel → Mixpanel Swift

mixpanel / Mixpanel Swift

Licence: other
Official iOS (Swift) Tracking Library for Mixpanel Analytics

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Mixpanel Swift

Countly Server
Countly helps you get insights from your application. Available self-hosted or on private cloud.
Stars: ✭ 4,857 (+1552.04%)
Mutual labels:  analytics, sdk, tracking
Mixpanel Iphone
iPhone tracking library for Mixpanel Analytics
Stars: ✭ 939 (+219.39%)
Mutual labels:  analytics, sdk, cocoapods
Mixpanel Android
Official Mixpanel Android SDK
Stars: ✭ 907 (+208.5%)
Mutual labels:  analytics, sdk, tracking
Amplitude Ios
Native iOS/tvOS/macOS SDK
Stars: ✭ 216 (-26.53%)
Mutual labels:  analytics, sdk, cocoapods
Amplitude Android
Native Android SDK for Amplitude
Stars: ✭ 129 (-56.12%)
Mutual labels:  analytics, sdk
Iotplatform
An open-source IoT platform that enables rapid development, management and scaling of IoT projects. With this IoT platform, you are able to: 1) Provision and control devices, 2) Collect and visualize data from devices, 3) Analyze device data and trigger alarms, 4) Deliver device data to other systems, 5) Enable use-case specific features using customizable rules and plugins.
Stars: ✭ 82 (-72.11%)
Mutual labels:  analytics, sdk
Wordpress Sdk
Stars: ✭ 162 (-44.9%)
Mutual labels:  analytics, sdk
React Tracker
React specific tracking library, Track user interaction with minimal API!
Stars: ✭ 191 (-35.03%)
Mutual labels:  analytics, tracking
Countly Sdk Web
Countly Product Analytics SDK for websites and web applications
Stars: ✭ 165 (-43.88%)
Mutual labels:  analytics, sdk
Keen Tracking.js
A light, fast and flexible javascript tracking library
Stars: ✭ 218 (-25.85%)
Mutual labels:  analytics, tracking
pageviews
A simple and lightweight pageviews counter for your WordPress posts and pages.
Stars: ✭ 23 (-92.18%)
Mutual labels:  tracking, analytics
Countly Sdk Cordova
Countly Product Analytics SDK for Cordova, Icenium and Phonegap
Stars: ✭ 69 (-76.53%)
Mutual labels:  analytics, sdk
Gumshoe
A we analytics and event tracking sleuth JavaScript library
Stars: ✭ 39 (-86.73%)
Mutual labels:  analytics, tracking
Vue Analytics
Google Analytics plugin for Vue
Stars: ✭ 1,780 (+505.44%)
Mutual labels:  analytics, tracking
Aurelia Google Analytics
An Aurelia.io plugin that adds Google Analytics page tracking to your project.
Stars: ✭ 28 (-90.48%)
Mutual labels:  analytics, tracking
Ios Consent Sdk
Configurable consent SDK for iOS
Stars: ✭ 178 (-39.46%)
Mutual labels:  analytics, sdk
Amplitude Javascript
JavaScript SDK for Amplitude
Stars: ✭ 234 (-20.41%)
Mutual labels:  analytics, sdk
swetrix-js
The JavaScript analytics client for Swetrix Analytics
Stars: ✭ 28 (-90.48%)
Mutual labels:  tracking, analytics
Rotki
A portfolio tracking, analytics, accounting and tax reporting application that protects your privacy
Stars: ✭ 689 (+134.35%)
Mutual labels:  analytics, tracking
svelte-google-analytics
Google Analytics component for Svelte
Stars: ✭ 41 (-86.05%)
Mutual labels:  tracking, analytics

Mixpanel Swift Library

Build Status Average time to resolve an issue Percentage of issues still open CocoaPods Compatible Carthage compatible Swift Package Manager compatible Apache License Documentation

Table of Contents

Introduction

Welcome to the official Mixpanel Swift Library

The Mixpanel Swift library for iOS is an open-source project, and we'd love to see your contributions! We'd also love for you to come and work with us! Check out Jobs for details.

If you are using Objective-C, we recommend using our Objective-C Library.

Current supported features

Our master branch and our releases are now on Swift 5.

If you wish to use our Swift 4.2 implementation, please point to the v2.6.1 release. For Swift 4/4.1 implementation, please point to the v2.4.5 release. For Swift 3 implementation, please point to the v2.2.3 release. For Swift 2.3 implementation, please point to the v1.0.1 release.

Our Swift library fully supports all of the Mixpanel features and has full parity with the Objective-C Library.

Installation

Swift Package Manager

It requires Xcode 12+ and v2.8.0+ release

Important: we only have support for iOS, for now, if you need integrations for other platforms(tvOS or macOS), please use other integration methods instead

  1. In Xcode, select File > Swift Packages > Add Package Dependency.
  2. Follow the prompts using the URL for this repository and a minimum semantic version of v2.8.0

Check out our swift integration guide » for more info.

CocoaPods

Our current release only supports CocoaPods version 1.4.0+

Mixpanel supports CocoaPods for easy installation. To Install, see our swift integration guide »

For iOS, tvOS, macOS, and App Extension integrations:

pod 'Mixpanel-swift'

Carthage

Mixpanel also supports Carthage to package your dependencies as a framework. Include the following dependency in your Cartfile:

github "mixpanel/mixpanel-swift"

Check out the Carthage docs » for more info.

Manual Installation

To help users stay up to date with the latest version of our Swift SDK, we always recommend integrating our SDK via CocoaPods, which simplifies version updates and dependency management. However, there are cases where users can't use CocoaPods. Not to worry, just follow these manual installation steps and you'll be all set.

Step 1: Add as a Submodule

Add Mixpanel as a submodule to your local git repo like so:

git submodule add [email protected]:mixpanel/mixpanel-swift.git

Now the Mixpanel project and its files should be in your project folder!

Step 2: Drag Mixpanel to your project

Drag the Mixpanel.xcodeproj inside your sample project under the main sample project file:

alt text

Step 3: Embed the framework

Select your app .xcodeproj file. Under "General", add the Mixpanel framework as an embedded binary:

alt text

Initializing and Usage

Integrate

Import Mixpanel into AppDelegate.swift, and initialize Mixpanel within application:didFinishLaunchingWithOptions: alt text

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    Mixpanel.initialize(token: "MIXPANEL_TOKEN")
}

You initialize your Mixpanel instance with the token provided to you on mixpanel.com.

Start tracking

After installing the library into your iOS app, Mixpanel will automatically collect common mobile events. You can enable/ disable automatic collection through your project settings.

To interact with the instance and track additional events, you can either use the mixpanel instance given when initializing:

mixpanel.track(event: "Tracked Event!")

or you can directly fetch the instance and use it from the Mixpanel object:

Mixpanel.mainInstance().track(event: "Tracked Event!")

You're done! You've successfully integrated the Mixpanel Swift SDK into your app. To stay up to speed on important SDK releases and updates, star or watch our repository on Github.

Have any questions? Reach out to [email protected] to speak to someone smart, quickly.

Using Mixpanel Push Notifications

First enable Mixpanel push notifications in your app. Then for Rich Push Notifications, you'll need to integrate your application with the MixpanelNotificationServiceExtension.

Integrating the MixpanelNotificationServiceExtension

The Mixpanel SDK comes with a custom Notification Service Extension used to render rich media, custom action buttons, and track when push notifications are received. To enable these features, you will need to integrate it into your application.

1. Create a new Notification Service Extension Target

Screenshot 2020-02-13 14 45 23 Screenshot 2020-02-13 14 44 38 Screenshot 2020-02-13 14 46 53

2. Add Mixpanel-swift as a dependency

Add the following to the end of your Podfile:

target 'NotificationService' do
  use_frameworks!
  
  pod 'Mixpanel-swift'
end

Then run pod install

3. Extend your NotificationService from MixpanelNotificationServiceExtension

Replace the contents of your NotificationService.swift file with the following:

import Mixpanel

class NotificationService: MixpanelNotificationServiceExtension {}

4. Delegate the handling of the notification response to the Mixpanel SDK

In your AppDelegate.swift file, you need to call MixpanelPushNotifications.handleResponse when a push notification response is received:

@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
    if MixpanelPushNotifications.isMixpanelPushNotification(response.notification.request.content) {
        debugPrint("Handling Mixpanel push notification response...")
        MixpanelPushNotifications.handleResponse(response: response, withCompletionHandler: completionHandler)
    } else {
        // not a Mixpanel push notification
        debugPrint("Not a Mixpanel push notification.")
        completionHandler()
    }
}

This will make sure the tap actions are appropriately handled (open URL, deeplink, etc) as well as track whether a notification was tapped or dismissed.

5. Run the app and send a test push notification from Mixpanel that includes an image or buttons

That's it! Your app should now be able to receive rich push notifications from Mixpanel.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].