Latest 1.0.1
License MIT
Platforms ios 9.3, requires ARC

GitHub release
Build Status
GitHub repo size

BaseTracking is the easiest way to setup your analytics in Swift.


  • iOS 9.3+
  • Swift 4.0+



BaseTracking is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'BaseTracking', '~> 1.0'

and run pod install


Just copy source folder to your project.

Framework > BaseTracking > Source

How to use

Example using Firebase Analytics:

Import library in your swift file

import BaseTracking

In your tracking manager file create an extension for BaseTrackingProtocol:

extension TrackingManager: BaseTrackingProtocol {
  func configure() {

  func track(event log: BaseTrackingEventLogData) {
    Analytics.logEvent(, parameters: log.parameters)

  func track(view data: BaseTrackingViewData) {
    Analytics.setScreenName(, screenClass: data.className)

And create another one to prepare protocol methods

extension BaseTrackingEventLog {
  static func trackView(name: ScreenName, className: ClassName? = nil) {
    let data = BaseTrackingViewData(
      name: name.rawValue as? String ?? "",
      className: className?.rawValue as? String
    TrackingManager.shared.track(view: data)

  static func trackEvent(name: EventName, parameters: EventParameters? = nil) {
    let data = BaseTrackingEventLogData(
      name: name.rawValue as? String ?? "",
      parameters: parameters?.rawValue as? [String: Any]
    TrackingManager.shared.track(event: data)

Now, create a tracking file for some area of the app.

struct HomeTracking: BaseTrackingEventLog {
  enum ScreenName: String {
    case home

  enum EventName: String {
    case showDetails = "show_home_details"

  typealias ClassName = CustomRawRepresentable
  typealias EventParameters = CustomRawRepresentable

extension HomeTracking {
  static func getSelectButtonParameter(_ value: Any) -> EventParameters? {
    let item: [String: Any] = ["button_name": value]
    return EventParameters(rawValue: item)

Than, let’s get tracking some data:

class HomeViewController: UIViewController {

  override func viewDidLoad() {

  override func viewWillAppear(_ animated: Bool) {
    HomeTracking.trackView(name: .home)

  @IBAction private func showDetails(sender: Any?) {
    let buttonName = (sender as? UIBarButtonItem)?.title ?? ""
    let parameters = HomeTracking.getSelectButtonParameter(buttonName)
    HomeTracking.trackEvent(name: .showDetails, parameters: parameters)

If you need examples unsing GA, take a look at demo project.


  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request. 👨🏻‍💻


BaseTracking is under MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "BaseTracking",
    "version": "1.0.1",
    "summary": "BaseTracking is the easiest way to setup your analytics in Swift",
    "requires_arc": true,
    "homepage": "",
    "license": "MIT",
    "authors": {
        "John Lima": "joh[email protected]"
    "social_media_url": "",
    "platforms": {
        "ios": "9.3"
    "source": {
        "git": "",
        "tag": "1.0.1"
    "source_files": "Framework/BaseTracking/Source/*.{swift}",
    "swift_version": "4.0"

Pin It on Pinterest

Share This