Install guides / Mobile apps

Add PageLens analytics to iOS app (Swift)

PageLens is cookieless website analytics: no consent banner, a ~3 KB script, real-time stats, funnels, session replay and AI-traffic insights. Setup on iOS app (Swift) takes about two minutes.

Steps

  1. In Xcode choose File → Add Package Dependencies… and enter https://github.com/alibaizhanov/pagelens-ios (or download PageLens.swift from https://app.pagelens.io/sdk/ios/PageLens.swift and drag it in) — no dependencies, iOS 14+.
  2. Call PageLens.configure(siteId:) once at launch.
  3. Mark screens with .pageLensScreen("Name") in SwiftUI (or PageLens.screen("Name") in viewDidAppear for UIKit) and actions with PageLens.track("event").
  4. Nothing is stored on the device and no advertising identifier is used, so no App Tracking Transparency prompt is needed. In App Store Connect, list “Product Interaction” under App Privacy as used for Analytics and not linked to the user (linked only if you call identify).
  5. Screens appear as pages like /Settings, and the app version shows under Browsers.
import SwiftUI
import PageLens

@main
struct MyApp: App {
    init() {
        PageLens.configure(siteId: "YOUR_SITE_ID")
    }
    var body: some Scene {
        WindowGroup {
            ContentView()
                .pageLensScreen("Home")
        }
    }
}

// Actions and signed-in users, anywhere in the app:
PageLens.track("signup", properties: ["plan": "pro"])
PageLens.identify(user.id)

Replace YOUR_SITE_ID with the id from your site settings in PageLens. The dashboard shows the exact snippet with your id filled in.

Check that it works

Open your site in a new tab, then open PageLens. The live counter shows your visit within a few seconds. Visits from localhost are ignored by default.

Track custom events

Add data-pagelens-event to any button or form, or call the JavaScript API:

<button data-pagelens-event="signup" data-pagelens-prop-plan="pro">Start trial</button>

<script>
  window.pagelens?.track('signup', { plan: 'pro' })
</script>

You can also turn on autocapture for button clicks, form submissions and copy events in Site Settings → Tracking. No code is needed.

Avoid ad blockers

Some ad blockers drop requests to analytics domains. Serve PageLens from your own domain to count those visits too.

Don't have a site ID yet?

Create a free PageLens account: 7-day trial, no card, no cookie banner needed.

Start free trial

Other mobile apps

React Native / Expo