Swiftpack.co - Package - samtgarson/FathomAnalytics


Swift Package Manager

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"))


Quick Start

  1. Import FathomAnalytics and instantiate a new client instance with your Fathom config:
import FathomAnalytics

let analytics = FathomAnalyticsClient(siteID: siteID, environment: environment)
  1. Track a page view:
analytics.track(page: "account")
  1. Track a goal:
analytics.track(goal: "MFTZ2U9V", value: 30)

Example Usage

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) ⚠️ Known issue: this currently has to be in the form of a url for Fathom to register a page view (e.g. 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.


Stars: 0

Used By

Total: 0


v0.0.1 -

Initial release 🎉