pasar libgoogleanalyticsservices google app ios iphone ipad google-analytics

ios - app - libgoogleanalyticsservices a



Google Analytics en iOS(no funciona) (4)

Estoy tratando de implementar Google Analytics ... ¿podrían ayudarme?

-(void) setGoogleAnalytics{ // Initialize tracker. self.tracker = [[GAI sharedInstance] trackerWithName:@"ipad app" trackingId:kTrackingID]; NSDictionary *appDefaults = @{kAllowTracking: @(YES)}; [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; // User must be able to opt out of tracking [GAI sharedInstance].optOut = ![[NSUserDefaults standardUserDefaults] boolForKey:kAllowTracking]; // Optional: automatically send uncaught exceptions to Google Analytics. [GAI sharedInstance].trackUncaughtExceptions = YES; // Optional: set Google Analytics dispatch interval to e.g. 20 seconds. [GAI sharedInstance].dispatchInterval = 5; // Optional: set Logger to VERBOSE for debug information. [[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose]; [[GAI sharedInstance] setTrackUncaughtExceptions:YES]; }

y llamándolo

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ [self setGoogleAnalytics]; // // // }

Dentro de la implementación de My ViewController

[self dispatchEvent:@"Purchase Done"]; [self trackViewName:NSStringFromClass([self class])]; -(void) trackViewName:(NSString *) strClassName{ [[GAI sharedInstance] defaultTracker]; self.screenName=[NSString stringWithFormat:@"%@",strClassName]; [self.tracker send:[[NSDictionary alloc] initWithObjectsAndKeys:strClassName,@"ViewName", nil]]; [[GAI sharedInstance] dispatch]; } - (void)dispatchEvent:(NSString *)strButtonText{ id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker]; [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui_action" // Event category (required) action:@"button_press" // Event action (required) label:strButtonText // Event label value:nil] build]]; // Event value = [[GAI sharedInstance] defaultTracker]; [[GAI sharedInstance] dispatch]; }

¿Qué versión de Google Analytics, debo descargar actualmente? He descargado google GoogleAnalyticsServicesiOS_3.01.zip (recomendado) ya que no quiero trabajar con la versión beta GoogleAnalyticsiOS_2.0beta4.zip


Tuve el mismo problema con 3.01. Mi problema fue en realidad en la sección de administración de Google Analytics.

Tenía una configuración de perfil para dispositivos móviles (que en realidad estaba configurada como si fuera un sitio web) que funcionaba con la versión 1.x. Sin embargo, parece que Google también ha implementado perfiles "móviles". Creo que los SDK móviles 3.x no pueden rastrear perfiles "web".

Crea un nuevo perfil siguiendo las instrucciones aquí. Y luego use el nuevo ID de seguimiento y debería comenzar a rastrear.

Nota: No configure el dispatchInterval en 0, como otros han sugerido, esto también impidió el seguimiento, configúrelo en 1. Esto solucionó todo por mí.


#import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @protocol GAITracker; @interface GAITrackedViewController : UIViewController { @private id<GAITracker> tracker_; NSString *trackedViewName_; } @property(nonatomic, assign)id<GAITracker> tracker; @property(nonatomic, copy)NSString *trackedViewName; @end Paste this code on "GAITrackedViewController.h" file Then you can use self.trackedName = @"Some Name"; easly.


ACTUALIZACIÓN - Google Analytics SDK para iOS v3

Así que estoy usando v3, y no hay ningún problema:

Lo implementé en AppDelegate. En archivo .h:

#import "GAI.h" @property (nonatomic,assign) id<GAITracker> tracker; // I''m not using ARC (assign)

.metro:

#import "GAIDictionaryBuilder.h" #import "GAIFields.h" // GOOGLE ANALYTICS [GAI sharedInstance].trackUncaughtExceptions = YES; [GAI sharedInstance].dispatchInterval = 0; tracker = [[GAI sharedInstance] trackerWithTrackingId:@"yourGAID"];

Y escribe un método como este:

- (void) sendGoogleAnalyticsView:(NSString*)viewName{ [tracker set:kGAIScreenName value:viewName]; [tracker send:[[GAIDictionaryBuilder createAppView] build]]; [[GAI sharedInstance] dispatch]; // this will force track your views. }

Respuesta anterior:

Vea esta respuesta debajo de este enlace, si lo hace igual que dije en esta respuesta, debe funcionar

Otro desbordamiento de pila respondió preguntas sobre google-analytics

y usa estos métodos:

[GAI sharedInstance].optOut = YES; [GAI sharedInstance].dispatchInterval = 0; [GAI sharedInstance].trackUncaughtExceptions = YES; tracker = [[GAI sharedInstance] trackerWithTrackingId:@"YOUR TRACKERID"]; [tracker sendView:@"Your View name"]; [tracker sendEventWithCategory:@"YOUR CATEGORY" withAction:@"YOUR ACTION" withLabel:nil withValue:nil];

Descargue GoogleAnalyticsiOS_2.0beta4.zip desde este enlace , que contendrá las clases que necesita y funcionará perfectamente. Tenga cuidado, Google Analytics obtuvo un tiempo de entrega, para mostrarle información, sobre tiempo real. Y los datos en tiempo real no se mostrarán solo un día después

EDITAR para 3.0:

Encontré algunas cosas probablemente útiles para ti:

Acabamos de encontrarnos con este problema y está un poco desactualizado, así que aquí hay una respuesta actualizada. El problema que teníamos después de seguir las instrucciones en el sitio web de Google Analytics, le indican que agregue los siguientes archivos GAI.h , GAIDictionaryBuilder.h , GAILogger.h , GAITrackedViewController.h , GAITracker.h y libGoogleAnalytics_debug.a library. Lo que olvidan por completo incluir en las instrucciones del sitio web es aquél en el que debe incluir la biblioteca libGoogleAnalyticsServices.a . Esto está incluido en la descarga comprimida, pero no hay instrucciones para indicar que se incluya esto en la versión de depuración.

Nota: En el libGoogleAnalyticsServices.a readme.txt, libGoogleAnalyticsServices.a se conoce simplemente como libGoogleAnalytics.a Google no ha podido actualizar su documentación para incluir el nuevo nombre o las instrucciones correctas que indican que esto es necesario en la depuración.

Archivos y bibliotecas que más se incluirán

GAI.h GAIDictionaryBuilder.h GAIFields.h GAILogger.h GAITrackedViewController.h GAITracker.h libGoogleAnalytics.a // Also know as libGoogleAnalyticsServices.a libGoogleAnalytics_debug.a

más información:

Estoy bastante seguro de que Google todavía no ha proporcionado una versión arm64 de sus libGoogleAnalyticsServices.a , lo cual es realmente molesto ... han pasado semanas desde que se publicó el lanzamiento de Xcode 5GM.

Por ahora, supongo que solo compilar para armv7, armv7s o eliminar google analytics hasta que obtengan su cabeza fuera de sus pantalones.

Aquí hay una Guía de inicio de iOS. para implementarlo.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Optional: automatically send uncaught exceptions to Google Analytics. [GAI sharedInstance].trackUncaughtExceptions = YES; // Optional: set Google Analytics dispatch interval to e.g. 20 seconds. [GAI sharedInstance].dispatchInterval = 0; // Optional: set Logger to VERBOSE for debug information. [[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose]; // Initialize tracker. id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXX-Y"]; }

Para enviar manualmente una vista de pantalla, establezca los valores del campo de pantalla en el rastreador y luego envíe el acierto:

// May return nil if a tracker has not already been initialized with a // property ID. id tracker = [[GAI sharedInstance] defaultTracker]; // This screen name value will remain set on the tracker and sent with // hits until it is set to a new value or to nil. [tracker set:kGAIScreenName value:@"Home Screen"]; [tracker send:[[GAIDictionaryBuilder createAppView] build]];

O Medición de pantalla automática:

Mida automáticamente las vistas como pantallas usando la clase GAITrackedViewController . Haga que cada uno de los controladores de vista extienda GAITrackedViewController y agregue una propiedad llamada screenName. Esta propiedad se usará para establecer el campo de nombre de pantalla.

// // MyViewController.h // An example of using automatic screen tracking in a ViewController. // #import "GAITrackedViewController.h" // Extend the provided GAITrackedViewController for automatic screen // measurement. @interface AboutViewController : GAITrackedViewController @end // // MyViewController.m // #import "MyViewController.h" #import "AppDelegate.h" @implementation MyViewController - (void)viewDidLoad { [super viewDidLoad]; // Set screen name. self.screenName = @"Home Screen"; } // Rest of the ViewController implementation. @end

Seguimiento de eventos:

enlazar

Para enviar un evento a Google Analytics, use GAIDictionaryBuilder.createEventWithCategory: action: label: value: y envíe el hit, como en este ejemplo:

// May return nil if a tracker has not already been initialized with a property // ID. id<GAITracker> = [[GAI sharedInstance] defaultTracker]; [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui_action" // Event category (required) action:@"button_press" // Event action (required) label:@"play" // Event label value:nil] build]]; // Event value


En el archivo AppDElegate.m :

#import "AppDelegate.h" #import "GAI.h" - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [GAI sharedInstance].trackUncaughtExceptions = YES; [GAI sharedInstance].dispatchInterval = 1; [[[GAI sharedInstance] logger]setLogLevel:kGAILogLevelVerbose]; id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"TrackingId"]; [GAI sharedInstance].defaultTracker = tracker; return YES; }

En ViewController.h

#import <UIKit/UIKit.h> #import "GAITrackedViewController.h" @interface FirstViewController : GAITrackedViewController @end

En ViewController.m

- (void)viewDidLoad { [super viewDidLoad]; self.screenName = @"RED Screen"; }

Intentalo. Esto funcionó para mí muy bien. Lo intenté con más de tres aplicaciones. Y todos están trabajando en tiempo real. Si su cuenta para su aplicación es nueva , es posible que tenga que esperar 24 horas o más para ver el resultado. A veces lleva tiempo mostrar datos en tiempo real sin ningún motivo.

A veces tampoco funciona debido a la antigua SDK de Google Analytics. Para obtener la última versión de SDK, puede usar la tableta de cacao. aquí está el procedimiento:

platform :ios, ''10.0'' target “GoogleAnalyticsTestApp” do pod ''GoogleAnalytics'' end

Escriba estas líneas en su archivo pod en su directorio de proyecto y guárdelo. luego instala el pod. Para saber cómo instalar el cocoa pod ver el enlace:

Error al importar el SDK de iOS de Google Analytics con las cápsulas de cacao

No escriba Google / Analytics. Escribe GoogleAnalytics. Espero que resolverá el problema.