FathomAnalytics
An experimental Swift client to allow you to track your iOS users using Fathom Analytics.
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Once you have your Swift package set up, adding FathomAnalytics as a dependency is as easy as adding it to the dependencies value of your Package.swift.
dependencies: [
.package(url: "https://github.com/samtgarson/FathomAnalytics.git", .upToNextMajor(from: "0.0.1"))
]
- Import FathomAnalytics and instantiate a new client instance with your Fathom config:
import FathomAnalytics
let analytics = FathomAnalyticsClient(siteID: siteID, environment: environment)
- Track a page view:
analytics.track(page: "account")
- Track a goal:
analytics.track(goal: "MFTZ2U9V", value: 30)
For an example usage of this package to track pages and goals, check out this SwiftUI project.
Parameter | Required | Description |
---|---|---|
siteID |
* | Your Fathom site ID (something like ABCDEFGH ) |
environment |
* | A string to identify the environment you're reporting from (this is to replace the concept of "host" in a web browser) https://my-app.yourdomain.com/development ) |
url |
Your custom URL setup in Fathom, if you have one (defaults to Fathom's global API URL) | |
logger |
Provide a custom, swift-log compliant, logging backend (defaults to logging to stdout ) |
To track a page:
Parameter | Required | Description |
---|---|---|
page |
* | An identifier for the current page (replacing the concept of "path" in a web browser) |
To track a goal:
Parameter | Required | Description |
---|---|---|
goal |
* | The code for your goal (something like ABCD1E2F ) |
value |
The value of the goal, in cents |
Bug reports and pull requests are welcome on GitHub at https://github.com/samtgarson/FathomAnalytics. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The module is available as open source under the terms of the MIT License.