{"id":19233692,"url":"https://github.com/brightdigit/gampkit","last_synced_at":"2025-08-13T19:45:56.924Z","repository":{"id":45888957,"uuid":"245285308","full_name":"brightdigit/GampKit","owner":"brightdigit","description":"Google Analytics Measurement Protocol API for Swift","archived":false,"fork":false,"pushed_at":"2022-01-12T19:00:42.000Z","size":220,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-17T13:37:50.545Z","etag":null,"topics":["cocoapods","google-analytics","google-analytics-api","macos","measure-protocol-api","measurement-protocol","swift","watchos","xcode"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brightdigit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-05T23:03:49.000Z","updated_at":"2025-01-20T07:30:38.000Z","dependencies_parsed_at":"2022-09-12T21:14:16.128Z","dependency_job_id":null,"html_url":"https://github.com/brightdigit/GampKit","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":"brightdigit/EggSeed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdigit%2FGampKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdigit%2FGampKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdigit%2FGampKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdigit%2FGampKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brightdigit","download_url":"https://codeload.github.com/brightdigit/GampKit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249996248,"owners_count":21358096,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapods","google-analytics","google-analytics-api","macos","measure-protocol-api","measurement-protocol","swift","watchos","xcode"],"created_at":"2024-11-09T16:11:33.023Z","updated_at":"2025-04-21T04:33:23.350Z","avatar_url":"https://github.com/brightdigit.png","language":"Swift","readme":"![Logo of the project](https://raw.githubusercontent.com/brightdigit/GampKit/master/logo.png)\n\n# GampKit\n\n[![SwiftPM](https://img.shields.io/badge/SPM-Linux%20%7C%20iOS%20%7C%20macOS%20%7C%20watchOS%20%7C%20tvOS-success?logo=swift)](https://swift.org)\n[![Twitter](https://img.shields.io/badge/twitter-@brightdigit-blue.svg?style=flat)](http://twitter.com/brightdigit)\n![GitHub](https://img.shields.io/github/license/brightdigit/GampKit)\n![GitHub issues](https://img.shields.io/github/issues/brightdigit/GampKit)\n[![Beerpay](https://img.shields.io/beerpay/brightdigit/GampKit.svg)](https://beerpay.io/brightdigit/GampKit)\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/brightdigit/GampKit/GampKit?label=Actions\u0026logo=github)\n[![Travis (.com)](https://img.shields.io/travis/com/brightdigit/GampKit?logo=travis)](https://travis-ci.com/brightdigit/GampKit)\n[![CircleCI](https://img.shields.io/circleci/build/github/brightdigit/GampKit?label=xenial\u0026logo=circleci\u0026token=609e569b2dd9e85f571b788f67a857a1b7905773)](https://circleci.com/gh/brightdigit/GampKit)\n[![Bitrise](https://img.shields.io/bitrise/7b69b24b7c56684a?label=macOS\u0026logo=bitrise\u0026token=eOT7evPhInsR8U_JnSih_w)](https://app.bitrise.io/app/7b69b24b7c56684a)\n\n[![Codecov](https://img.shields.io/codecov/c/github/brightdigit/GampKit)](https://codecov.io/gh/brightdigit/GampKit)\n[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/brightdigit/GampKit)](https://www.codefactor.io/repository/github/brightdigit/GampKit)\n[![codebeat badge](https://codebeat.co/badges/4f86fb90-f8de-40c5-ab63-e6069cde5002)](https://codebeat.co/projects/github-com-brightdigit-GampKit-master)\n[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/brightdigit/GampKit)](https://codeclimate.com/github/brightdigit/GampKit)\n[![Code Climate technical debt](https://img.shields.io/codeclimate/tech-debt/brightdigit/GampKit?label=debt)](https://codeclimate.com/github/brightdigit/GampKit)\n[![Code Climate issues](https://img.shields.io/codeclimate/issues/brightdigit/GampKit)](https://codeclimate.com/github/brightdigit/GampKit)\n\n[![Version](https://img.shields.io/cocoapods/v/GampKit.svg?style=flat)](https://cocoapods.org/pods/GampKit)\n[![License](https://img.shields.io/cocoapods/l/GampKit.svg?style=flat)](https://cocoapods.org/pods/GampKit)\n[![Platform](https://img.shields.io/cocoapods/p/GampKit.svg?style=flat)](https://cocoapods.org/pods/GampKit)\n![Cocoapods doc percentage](https://img.shields.io/cocoapods/metrics/doc-percent/GampKit)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)\n\n\n\u003e Using Google Analytics for Tracking Events, Timing, Errors and more\n\nRather than downloading large amounts of libraries framework in order to understand how your app is used, you can use this library for easy data. The library works directly with Google Analytics using their Measure Protocol API. See all your data right from the Google Analytics dashboard.\n\n## Features\n\nIncluded with this library is the ability to track:\n\n- [x] Events with Custom Data\n- [x] Timing of various operations\n- [x] Swift Errors and NSExceptions\n- [x] Custom actions such screens and transactions\n\n## Reqirements\n\n- iOS 8.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+ / Linux \n- Xcode 10.2+\n- Swift 5+\n\n## Installing \n\n### CocoaPods\n\n[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate GampKit into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\npod 'GampKit', '~\u003e 0.1.0'\n```\n\n### Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. GampKit does support its use on supported platforms.\n\nOnce you have your Swift package set up, adding GampKit as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/brightdigit/GampKit.git\", .upToNextMajor(from: \"0.1.0\"))\n]\n```\n\n## Usage\n\n### [API Documentation](/Documentation/Reference/README.md)\n\nBefore moving forward make sure to setup a property under your Google Analytics account. With your new property for your application, you will need your _tracking identifier_. Typically a _tracking identifier_ has a format of `UA-XXXXXXXXX-XX`. You will need the _tracking identifier_ as well as the:\n\n- **Application Name**\n- **Application Version**\n- **Client Identifier** - this should be a ananymous UUID created on application installation and saved to future use on launch\n\n### Configuration\n\nIn order to begin tracking, you will need to setup a `AnalyticsTracker` with the configuration of your application using a `AnalyticsConfiguration` object:\n\n```swift\n  let tracker = AnalyticsTracker(configuration: AnalyticsConfiguration(\n    trackingIdentifier: \"UA-XXXXXXXX-XX\",\n    applicationName: \"GampKitDemo\",\n    applicationVersion: \"1.0\",\n    clientIdentifier: clientIdentifer\n  ))\n```\n\nNow that you have setup your `AnalyticsTracker`, let's being tracking events.\n\n### Tracking\n\nThere are three types of tracking objects: Events, Timing, and Exceptions.\n\n#### Events\n\nFor tracking events, you can create an `AnalyticsEvent` with a category and action:\n\n```swift\n    let event = AnalyticsEvent(category: \"category\", action: \"action\")\n    tracker.track(event) { result in\n      if case let .failure(error) = result {\n        debugPrint(error)\n      }\n    }\n```\n\nYou can read [more details about events on the Google Analytics Measurement Protocol documentation.](https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#event)\n\n#### Timing\n\nFor tracking timing, you can create an `AnalyticsTiming` or use `AnalyticsTracker.track(time:...)` with a category and action:\n\n```swift\n    let start : Date\n    ...\n    let timing = start.timeIntervalSinceNow\n    tracker.track(time: -timing, withCategory: \"jsonLoader\", withVariable: \"load\") { result in\n      if case let .failure(error) = result {\n        debugPrint(error)\n      }\n    }\n```\n\nYou can read [more details about timing on the Google Analytics Measurement Protocol documentation.](https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#usertiming)\n\n#### Errors and Exceptions\n\nFor tracking errors and exceptions, you can use `AnalyticsTracker.track(error:...)`:\n\n```swift\n    do {\n      try doSomething()\n    } catch let error {\n      tracker.track(error: error, isFatal: false) { result in\n        if case let .failure(error) = result {\n          debugPrint(error)\n        }\n      }\n    }\n```\n\nYou can read [more details about events on the Google Analytics Measurement Protocol documentation.](https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#exception)\n\n#### Custom Items\n\nYou can also track custom items by implementing `AnalyticsTrackable`. This requires the implmentation of two methods:\n\n```swift\n  var hitType: AnalyticsHitType {\n    get\n  }\n\n  func parameters() -\u003e AnalyticsParameterDictionary\n```\n\nAn `AnalyticsParameterDictionary` is simply a dictionary with keys of type `AnalyticsParameterKey`.\n\n```swift\npublic typealias AnalyticsParameterDictionary = [AnalyticsParameterKey: Any]\n\npublic enum AnalyticsParameterKey: String, CaseIterable {\n  case hitType = \"t\", version = \"v\", trackingId = \"tid\",\n    userTimingCategory = \"utc\", userTimingLabel = \"utl\", timing = \"utt\", clientId = \"cid\",\n    userTimingVariable = \"utv\",\n    applicationName = \"an\", applicationVersion = \"av\", eventAction = \"ea\",\n    eventCategory = \"ec\", eventLabel = \"el\", eventValue = \"ev\",\n    userLanguage = \"ul\", operatingSystemVersion = \"cd1\", model = \"cd2\",\n    exceptionDescription = \"exd\", exceptionFatal = \"exf\"\n}\n```\n\nThe rules regarding what are required based on hit type and each parameter is located in the [Google Analytics Measurement Protocol Parameter Reference.](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters)\n\n### Debugging vs. Release\n\nBy default, the library will either use the Google Analytics Measurement Protocol API url for validation purposes or the actual url depending on whether the build is `DEBUG` or `RELEASE`. When using the validation server, no items will be actually be tracked only validated. You can override this in one of two ways:\n\n1. Supply a custom URL for the AnalyticsSessionManager\n\n  ```swift\n    let tracker = AnalyticsTracker(configuration: AnalyticsConfiguration(\n      trackingIdentifier: \"UA-XXXXXXXX-XX\",\n      applicationName: \"GampKitDemo\",\n      applicationVersion: \"1.0\",\n      clientIdentifier: clientIdentifer\n    ), sessionManager: AnalyticsURLSession(url : url))\n  ```\n\n2. Use the debug mode flag for using the validation server \n\n  ```swift\n    let tracker = AnalyticsTracker(configuration: AnalyticsConfiguration(\n      trackingIdentifier: \"UA-XXXXXXXX-XX\",\n      applicationName: \"GampKitDemo\",\n      applicationVersion: \"1.0\",\n      clientIdentifier: clientIdentifer\n    ), debugMode: false)\n  ```\n\n## Links\n\n- Google Analytics Measurement Protocol API\n  - https://developers.google.com/analytics/devguides/collection/protocol/v1\n- Repository\n  - https://github.com/brightdigit/GampKit/\n- Issue tracker\n  - https://github.com/brightdigit/GampKit/issues\n\n## License\n\nGampKit is released under the MIT license. [See LICENSE](https://github.com/brightdigit/GampKit/blob/master/LICENSE) for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightdigit%2Fgampkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrightdigit%2Fgampkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightdigit%2Fgampkit/lists"}