Google Analytics tracker for Apple tvOS provides an easy integration of Google Analytics’ measurement protocol for Apple TV.

Overview

Google Analytics tracker for Apple tvOS

by Adswerve

About

Google Analytics tracker for Apple tvOS provides an easy integration of Google Analytics’ measurement protocol for Apple TV. This library enables sending screenviews, events, exceptions and any other hit type to Google Analytics. Implementation of the library and sending an initial hit to Google Analytics takes only a few minutes.

Implementation

All code for this tracker is located inside a single file “GATracker.swift”. The first step of the implementation is associating this library file with your application project.

This library creates an object (a tracker) that holds persistent values such as client id, property id, and more. The tracker is created with the following command:

GATracker.setup("UA-1234567-89")

This code should run in the AppDelegate method applicationDidFinishLaunchingWithOptions.

Hit Examples

Once the tracker is set up you can start sending Google Analytics hits from your Apple TV application.

Screenview

When sending the screenview hit type, the screenname parameter is a required field.

GATracker.sharedInstance.screenView("FirstScreen", customParameters: nil)

Event

When sending the event hit type, the event category and action a required fields

GATracker.sharedInstance.event("category", action: "action", label: nil, customParameters: nil)

Exception

When sending the exception hit, the exception description and exception “fatality” are both required parameters

GATracker.sharedInstance.exception("This test failed", isFatal: true, customParameters: nil)

Sending Additional Parameters

With each hit you are also able to send additional parameters as specified in the Measurement Protocol reference. Examples include: “non interactive hit”, “event value”, “custom dimensions”, “custom metrics” etc.

In the following example we will add custom metric values and set this event hit as non interactive. The example shows how to send a video progress hit that includes video name as custom dimension 1, video author as custom dimension 2 and sets the event as non interactive (since this event is not a result of user interaction).

GATracker.sharedInstance.event("Video", action: "Progress", label:"50%", customParameters: ["cd1":"Incredible Video", "cd2":"Amazing A. Uthor", "ni":1])

As mentioned before you are able to use any measurement protocol parameters inside the customParameters dictionary. https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters?hl=en

Sending Other Hit Types to Google Analytics

Screenview, event and exception are not the only hit types available in Google Analytics, to send a different hit such as a transaction, item, social or timing hit use the send function.

In the following example we will send a transaction hit with transaction id 10001 and transaction revenue of $425,00.

GATracker.sharedInstance.send("transaction", params: ["tid":"10001", "tr":"425,00", "cu":"USD"])

For additional information email [email protected] or visit our website http://www.analyticspros.com

Sample App

When running the sample app make sure ot update the property id in the app delegate.

GATracker.setup("[insert your GA property id]")
You might also like...
Timekeeper is an easy-to-use time measurement library written in Swift, with support for iOS, tvOS, watchOS and macOS.
Timekeeper is an easy-to-use time measurement library written in Swift, with support for iOS, tvOS, watchOS and macOS.

Timekeeper is an easy-to-use time measurement library written in Swift, with support for iOS, tvOS, watchOS and macOS. Installation Timekee

Gumlet analytics integration with AVPlayer for iOS native applications.

gumlet-Insights-avplayer Gumlet Insights integration with AVPlayer for iOS native applications. This Insights enables you to get useful data about vid

A drink tracker for iOS with Untappd and HealthKit integration.
A drink tracker for iOS with Untappd and HealthKit integration.

Good Spirits is a drink tracking iOS app that helps you stay under the government limits for "low-risk" drinking. Includes charts and stats, the abili

Analytics layer abstraction, abstract analytics reporters and collect domain-driven analytic events.

🐙 Tentacles Current State: Work in Progress Documentation & Tests(100% completed, but needs refactoring and structuring) started but not done yet, im

Social Media platform build with swiftUI and Firebase with google and apple account integration for Signing In Users
Social Media platform build with swiftUI and Firebase with google and apple account integration for Signing In Users

Social Media platform build with swiftUI and Firebase with google and apple account integration for Signing In Users . Providing Users availability to upload posts and images add caption allowing other users to comment , with Find section to explore new people , new stories , User Profile section to allow the user to take control of his account .

AZSafariCollectionViewLayout is replica of safari browser history page layout. very easy to use, IBInspectable are given for easy integration
AZSafariCollectionViewLayout is replica of safari browser history page layout. very easy to use, IBInspectable are given for easy integration

AZSafariCollectionViewLayout Features iOS Safari history view layout IBDesignAble for properties Few minutes integration Installation CocoaPods CocoaP

UITextField-based control for (NS)Measurement values input.
UITextField-based control for (NS)Measurement values input.

MeasurementTextField UITextField-based control for (NS)Measurement values input. Provides type-safe keyboard and picker based input of different measu

Synatax sugar for Measurement of Foundation.

WrappedMeasurement 2022 © Weizhong Yang a.k.a zonble Syntax sugar for NSMeasurement of Foundation. NSMeasurement and NSUnit compose a great tool to le

HumanMeasurementSwift - Synatax sugar for Measurement of Foundation

HumanMeasurement 2022 © Weizhong Yang a.k.a zonble Syntax sugar for NSMeasuremen

❤️ Continuous heart rate measurement during workouts with watchOS 3.

Heart Control Monitor your heart rate on the apple watch - continuously and easy. What is it? Heart Control is a standalone watch app to monitor conti

A Swift app, named 'iPose', for iPhone's pose measurement based on Swift.

iPhone's pose measurement based on Swift. This is a Swift app, named 'iPose', for iPhone's pose measurement based on Swift. This is a side project to

🛰 CoreLocation Made Easy - Efficient & Easy Location Tracker, IP Location, Gecoder, Geofence, Autocomplete, Beacon Ranging, Broadcaster and Visits Monitoring
🛰 CoreLocation Made Easy - Efficient & Easy Location Tracker, IP Location, Gecoder, Geofence, Autocomplete, Beacon Ranging, Broadcaster and Visits Monitoring

Location Manager Made Easy SwiftLocation is a lightweight Swift Library that provides an easy way to work with location-related functionalities. No mo

🛰 CoreLocation Made Easy - Efficient & Easy Location Tracker, IP Location, Gecoder, Geofence, Autocomplete, Beacon Ranging, Broadcaster and Visits Monitoring
🛰 CoreLocation Made Easy - Efficient & Easy Location Tracker, IP Location, Gecoder, Geofence, Autocomplete, Beacon Ranging, Broadcaster and Visits Monitoring

Location Manager Made Easy SwiftLocation is a lightweight Swift Library that provides an easy way to work with location-related functionalities. No mo

The hassle-free way to add Segment analytics to your Swift app (iOS/tvOS/watchOS/macOS/Linux).

Analytics-Swift The hassle-free way to add Segment analytics to your Swift app (iOS/tvOS/watchOS/macOS/Linux/iPadOS). Analytics helps you measure your

NextLevel is a Swift camera system designed for easy integration, customized media capture, and image streaming in iOS
NextLevel is a Swift camera system designed for easy integration, customized media capture, and image streaming in iOS

NextLevel is a Swift camera system designed for easy integration, customized media capture, and image streaming in iOS. Integration can optionally leverage AVFoundation or ARKit.

Versions tracker for your iOS, macOS, and tvOS app

VersionTrackerSwift VersionTrackerSwift is a versions / builds tracker to know which version has been installed by a user. Usage In your ApplicationDe

Matomo iOS, tvOS and macOS SDK: a Matomo tracker written in Swift

MatomoTracker (former PiwikTracker) iOS SDK The MatomoTracker is an iOS, tvOS and macOS SDK for sending app analytics to a Matomo server. MatomoTracke

Versions tracker for your iOS, macOS, and tvOS app

VersionTrackerSwift VersionTrackerSwift is a versions / builds tracker to know which version has been installed by a user. Usage In your ApplicationDe

MyWeight is a body mass tracker focused on make easy to input new data and check your weight history

MyWeight MyWeight is a body mass tracker focused on make easy to input new data and check your weight history. Getting Started Environment prerequisit

Comments
  • Make GATracker subclass of NSObject& Added Objective-C sample project.

    Make GATracker subclass of NSObject& Added Objective-C sample project.

    In order to import swift file GATracker into file in a Objective-C project , subclassing NSObject is required. Attached a sample objective-c project for reference.

    opened by denniszxxc 1
  • How to create GATracker id (Ex. UA-1234567-89)

    How to create GATracker id (Ex. UA-1234567-89)

    Hi, GATracker.setup("UA-1234567-89"). Here, How we can create this id? I did in Google Analytics console. but I got property id only. I couldn't get above format. Please help to resolve it. Thanks.

    opened by mohanasundaramiosdev 0
  • Xcode tvos

    Xcode tvos

    I'm having issues using this in my existing project, i used the GAtracker in the AppDelegate.swift but then i get errors. I put the swift ga in there and ran the cmd but then i get errors on both file and Gatracker.

    opened by scottastafford5 0
YouTube video player for iOS, tvOS and macOS

About XCDYouTubeKit is a YouTube video player for iOS, tvOS and macOS. Are you enjoying XCDYouTubeKit? You can say thank you with a tweet. I am also a

Cédric Luthi 2.9k Dec 21, 2022
tvOS controls and extensions that add parallax effect to your application.

ParallaxView Summary Easy to use UIView, UICollectionViewCell with parallax effect and extensions to add this effect to any UIView. Rotate view using

PGS Software 466 Nov 13, 2022
Light and scrollable view controller for tvOS to present blocks of text

TvOSTextViewer Light and scrollable view controller for tvOS to present blocks of text Description TvOSTextViewer is a view controller to present bloc

David Cordero 45 Oct 27, 2022
Light wrapper of UIButton that allows extra customization for tvOS

FocusTvButton Light wrapper of UIButton that allows extra customization for tvOS If you would like to have the same level of customization in tablevie

David Cordero 68 Nov 12, 2022
📺 A tvOS button which truncates long text with '... More'.

TvOSMoreButton ?? A tvOS button which truncates long text with '... More'. The TvOSMoreButton is a simple view which aims to mirror the behavior of Ap

Chris Goldsby 56 Oct 27, 2022
PIN keyboard for tvOS

TvOSPinKeyboard PIN keyboard for tvOS Description TvOSPinKeyboard is a view controller that allows easily asking for PIN codes in tvOS. Requirements t

Zattoo 102 Oct 5, 2022
Light wrapper of UITableViewCell that allows extra customization for tvOS

TvOSCustomizableTableViewCell Light wrapper of UITableViewCell that allows extra customization for tvOS If you would like to have the same level of cu

Zattoo 31 Nov 9, 2022
TvOSSlider is an implementation of UISlider for tvOS.

TvOSSlider TvOSSlider is an implementation of UISlider for tvOS. Description and usage TvOSSlider palliates missing an implementation of UISlider for

Zattoo 36 Dec 12, 2022
Amplitude Analytics 0 Feb 1, 2022
Trackable is a simple analytics integration helper library. It’s especially designed for easy and comfortable integration with existing projects.

Trackable Trackable is a simple analytics integration helper library. It’s especially designed for easy and comfortable integration with existing proj

Vojta Stavik 145 Apr 14, 2022