Skip to content

Parsely Analytics SDK for iOS

License

Notifications You must be signed in to change notification settings

Parsely/AnalyticsSDK-iOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a0a579c · Jan 30, 2025
Apr 14, 2023
Nov 27, 2024
Jan 20, 2025
Jan 20, 2025
Nov 28, 2024
Nov 27, 2024
Nov 27, 2024
Apr 14, 2023
Nov 27, 2024
Jan 8, 2025
Mar 25, 2019
Mar 25, 2019
Apr 14, 2023
Apr 14, 2023
Mar 25, 2019
Nov 27, 2024
Apr 19, 2023
Apr 19, 2023
Jan 28, 2024
Apr 14, 2023

Repository files navigation

Build Status

Parsely Tracking on iOS

This repository contains the code necessary to build and test the Parsely tracking framework for iOS. It also includes a basic sample iOS app that can be used to interactively experiment with Parsely tracking. Full API documentation is available here.

The ParselyAnalytics SDK is available via CocoaPods.

Including ParselyAnalytics in a project

First, set up a local CocoaPods environment if you haven't already:

$ sudo gem install cocoapods

Then add the following to your the project's Podfile:

pod 'ParselyAnalytics'

Then, run pod install to install ParselyAnalytics as a dependency.

Using the tracker

In any file that uses Parsely Analytics functionality, include import ParselyAnalytics

At app startup, initialize the Parsely singleton. A good place to do this might be the top-level application delegate:

var parsely: Parsely?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    self.parsely = Parsely.sharedInstance

    // optionally call configure to set an API Key for all requests
    self.parsely.configure(siteId: "example.com")

    // other app initialization
    return true
}

Once you've done this, you can call tracking methods on self.parsely:

self.parsely.trackPageView(url: "http://mysite.com/story1")
self.parsely.startEngagement(url: "http://mysite.com/story2")
self.parsely.stopEngagement()

Design Notes

To conserve battery usage and network bandwidth, the SDK will batch pixel requests as they are made, and flush them periodically. Each pixel retains its creation timestamp regardless of when it was sent. Upon app shutdown, or when the app is backgrounded, it will flush whatever pixels are currently in the queue.