Google Analytics for Vapor

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: "", from: "0.0.1")

Register the config and the provider to your Application

let config = GoogleAnalyticsConfig(trackingID: "UA-12XXXXX-Y")
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



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! 😀


  • Swift Tools 4.0.0
View More Packages from this Author


Last updated: Fri Jun 02 2023 07:00:59 GMT-0500 (GMT-05:00)