Tutuorial of how I created GAReporter
pod 'GAReporter', :git => 'https://github.com/ji3g4kami/GAReporter.git'
import GAReporter
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
GAReporter.configure("UA-ZZZZZZZZZZ", verbose: true)
return true
}
}
You can track any event you wish to using the sendEvent()
method on the GAReporter
. Example:
func pruchaseBasketball() {
GAReporter.sendEvent(category: "Sports", action: "Purchase", label: "basketball", value: nil)
}
In many cases you'll want to track what "screens" that the user navigates to. A natural place to do that is in your ViewController
s viewDidAppear
.
import GAReporter
class ViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(false)
GAReporter.sendScreenView("ViewController")
}
}
Copyright 2018 David Wu