An open API service indexing awesome lists of open source software.

https://github.com/zunda-pixel/googleanalytics-swift

Google Analytics REST API Client for Swift
https://github.com/zunda-pixel/googleanalytics-swift

google googleanalytics swift

Last synced: about 2 months ago
JSON representation

Google Analytics REST API Client for Swift

Awesome Lists containing this project

README

          

## GoogleAnalytics Measurement Protocol for Swift

[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fzunda-pixel%2Fgoogleanalytics-swift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/zunda-pixel/googleanalytics-swift)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fzunda-pixel%2Fgoogleanalytics-swift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/zunda-pixel/googleanalytics-swift)

[GA4 Measurement Protocol](https://developers.google.com/analytics/devguides/collection/protocol/ga4)

```swift
let client = GoogleAnalytics(
httpClient: .urlSession(.shared),
apiSecret: "bCab-SdfDBi2L3ZPaYHYfw",
id: .firebase(
firebaseAppId: "1:211175559289:ios:121555f3c816aecc3cd5d8",
appInstanceId: UUID().uuidString.replacingOccurrences(of: "-", with: "")
)
)

let sessionId = UUID().uuidString.replacingOccurrences(of: "-", with: "")

try await client.send(for: .login(
method: "Email",
sessionId: sessionId,
engagementTime: 123
))
```