/google-analytics-provider

Google Analytics for Vapor

Primary LanguageSwiftMIT LicenseMIT



Google Analytics Provider


Swift 4.1 Vapor 3

A Vapor provider for Google Analytics - a pure Swift implementation of Google Analytics Measurement Protocol

Getting Started

In your Package.swift file, add the following

.package(url: "https://github.com/PoissonBallon/google-analytics-provider.git", from: "0.0.1")

Register the config and the provider to your Application

let config = GoogleAnalyticsConfig(trackingID: "UA-12XXXXX-Y")
services.register(config)
try services.register(GoogleAnalyticsProvider())

And you are all set. Interacting with the API is quite easy.

let gac = try req.make(GoogleAnalyticsClient.self)
gac.send(hit: .event(category: "API", action: "create TODO"))

And you can always check the documentation to see the required parameters for specific API calls.

Whats Implemented

Common Hit Types

  • Page Tracking
  • Event Tracking
  • Ecommerce Tracking
  • Social Tracking
  • Exception Tracking
  • User Timing Tracking
  • App / Screen Tracking

Error and Quotas

  • Too big hits
  • Malformed Hits

Author

License

Google Analytics Provider is available under the MIT license. See the LICENSE file for more info.

Want to help?

Feel free to submit a pull request whether it's a clean up, a new approach to handling things, adding a new part of the API, or even if it's just a typo. All help is welcomed! 😀