Giter Site home page Giter Site logo

jotamelo / ga-tracker-for-apple-tvos Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adswerve/swift-ga-tracker-for-apple-tvos

2.0 3.0 0.0 47 KB

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

Home Page: http://www.analyticspros.com

License: MIT License

Objective-C 100.00%

ga-tracker-for-apple-tvos's Introduction

Google Analytics tracker for Apple tvOS

by Analytics Pros

Objective-C version by Jota Melo

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 in the "GATracker" class. The first step of the implementation is adding the .h and .m files to your 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 sharedInstance] setTrackingID:@"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] eventWithCategory:@"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] exceptionWithDescription:@"This test failed" fatal:YES 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] eventWithCategory:@"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" parameters:@{@"tid": @"10001", @"tr": @"425,00", @"cu": @"USD"}];

ga-tracker-for-apple-tvos's People

Contributors

lukadata avatar

Stargazers

Loreto Parisi avatar  avatar

Watchers

James Cloos avatar Jota Melo avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.