Skip to content

Instantly share code, notes, and snippets.

@matiasvillaverde
Last active May 18, 2018 14:44
Show Gist options
  • Save matiasvillaverde/827d7ee1047029d95094b3776f76ab86 to your computer and use it in GitHub Desktop.
Save matiasvillaverde/827d7ee1047029d95094b3776f76ab86 to your computer and use it in GitHub Desktop.
import GoogleAnalytics
class GoogleAnalytics: Analytics {
func setup() {
GAI.sharedInstance().tracker(withTrackingId: "UA-123456789-1")
}
func track(event: String) {
// Common you are google... this is not a nice way to design an API.
guard let tracker = GAI.sharedInstance().defaultTracker else { return }
let toSend = GAIDictionaryBuilder.createEvent(withCategory: event,
action: nil,
label: nil,
value: nil).build() as [NSObject: AnyObject]
tracker.send(toSend)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment