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")) ]
- 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:
- 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.
||*||Your Fathom site ID (something like
||*||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.
||Your custom URL setup in Fathom, if you have one (defaults to Fathom's global API URL)|
||Provide a custom,
To track a page:
||*||An identifier for the current page (replacing the concept of "path" in a web browser)|
To track a goal:
||*||The code for your goal (something like
||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.