Apps

Installs, updates, opens and screens from an iPhone, iPad or Mac app, with the version and device on every event.

An app is in the hands of the people who install it, so use a public key here, as on a web page. See Keys. A project’s list of allowed sites does not apply to an app: it has no address to check.

In Swift

Add the package https://github.com/snekot-co/snekot-swift from version 0.5.0, and create the client once, when the app starts:

import SnekotEvents

let snekot = SnekotEvents(token: "YOUR_PUBLIC_KEY", project: "your-project", queue: OfflineQueue(), app: AppAnalytics())

That line is the setup. Installs, updates and opens are sent from then on with no more code, and what is sent without a connection waits in the queue. The rest is yours to call:

try await snekot.screen("Checkout")                                          // which screen someone is on
try await snekot.track(channel: "orders", event: "Order placed")             // an event, as anywhere else
try await snekot.identify(userID: "user-123", properties: ["plan": "pro"])   // when someone signs in
snekot.reset()                                                               // when they sign out
  • screen names the screen a person is looking at. Give the same screen the same name every time; put what it shows, such as a product’s name, in title.
  • After identify, later events and screens are from that user, also after the app is restarted, and what they did before signing in is joined to them.
  • reset() forgets the user and starts a new visitor, so the next person on the device is not taken for the last one.

What an app sends by itself

Three events arrive in the app channel. They are ordinary events: they show in the feed, can be charted, put in a funnel, forwarded and pushed like any other.

Event When
📲 App installed The first launch on a device.
🆙 App updated The first launch of a new version or build, with the tags from, to, from_build and to_build.
📱 App opened A cold start, and coming back to the app after 30 minutes or more away.

Each can be switched off: AppAnalytics(lifecycle: [.installed, .updated]) leaves opens out, and [] sends none.

The first launch after you add the library to an app that is already out counts as an install for the people who already had it, since nothing on their device says otherwise. Expect one burst of installs with that release. An app deleted and installed again is a new install.

What goes with every event and screen

Field Example
visitor_id r_3q2-7wAAAAAAAAAAAAAAAA A random id made on the first launch and kept in the app’s own storage. It is not derived from the device.
version 2.4.1 The app’s version.
build 312 The app’s build number.
os iOS iOS, iPadOS, macOS, tvOS, watchOS or visionOS.
os_version 18.2 The system’s version.
model iPhone16,1 The hardware’s model. Shown by its name, such as iPhone 15 Pro.
kind phone phone, tablet, desktop, tv, watch or headset.
language sv-SE The person’s first preferred language.
screen_width, screen_height 393, 852 The screen’s size in points.

The country is worked out from the request when it arrives, as for a web page, and the address it came from is not kept.

None of this asks the person for permission. The advertising identifier, the vendor identifier, the device’s name and its location are never read.

Where it shows

Once an app has sent something, the project’s Views page gets a choice of All, Web and App. App shows the people using the app, opens, installs, updates and screen views over the period you choose, and who is on which version, system, device, country, language and screen. Web is the site alone, and All is both together. A project whose views all come from its app opens on App.

A screen is a page view, so screens are also in funnels and in the latest views, with the screen’s name where a web page has its path.

Privacy and the App Store

The package carries a privacy manifest, which Xcode merges into your app’s privacy report. It says the library does not track, contacts no tracking domains, and uses UserDefaults to keep its own few values.

For the App Store privacy label, declare under Analytics, not used for tracking:

  • Product Interaction: events and screens.
  • Device ID: the visitor id. It is random and belongs to your app alone, but it does tell one install from another.
  • Other Usage Data and Other Diagnostic Data: the details above.

Once you call identify, events are tied to your own user id, so declare these as linked to the user and add User ID. Anything personal you put in tags or properties is yours to declare too.

From any other app

The details are one more field in the API, so an Android, Flutter or React Native app can send them itself until it has a library that does. Add app and a visitor_id to an event:

curl https://api.snekot.co/v1/log \
  -H "Authorization: Bearer YOUR_PUBLIC_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "your-project",
    "channel": "app",
    "event": "App opened",
    "icon": "📱",
    "visitor_id": "r_3q2-7wAAAAAAAAAAAAAAAA",
    "app": { "version": "2.4.1", "build": "312", "os": "Android", "os_version": "15", "model": "Pixel 9", "kind": "phone", "language": "sv-SE" }
  }'

A screen goes to /v1/page, with the screen’s name as the path:

curl https://api.snekot.co/v1/page \
  -H "Authorization: Bearer YOUR_PUBLIC_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "your-project",
    "visitor_id": "r_3q2-7wAAAAAAAAAAAAAAAA",
    "payload": { "path": "Checkout", "title": "Your basket" },
    "app": { "version": "2.4.1", "build": "312", "os": "Android", "os_version": "15", "model": "Pixel 9", "kind": "phone" }
  }'
  • app.version is what marks a request as coming from an app; every other field is optional.
  • visitor_id is r_ followed by 16 to 40 letters, digits, - or _. Make it once at random and keep it on the device.
  • Installs, updates and opens are counted from the three events above by their names in the app channel, so send them with exactly those names.
  • Send visitor_id with /v1/identify too, and what that visitor did before signing in is joined to the user.