谷歌分析不在iOS中发送任何匹配? [英] Google analytics not sending any hits in iOS?
问题描述
我创建了示例项目并添加了基于Google教程的Google Analytics(分析)。
但是当我运行这个应用程序,我看不到任何命中应用程序发送。
我已经添加了所有这些库
1.libsqlite3.0.tbd
2.libGoogleAnalyticsServices.a
3.libsqlite3.dylib
4.libz.dylibs
5.CoreData.framework
6.SystemConfiguration.framework
也添加了这些库文件
1.GAI.h
2.GAIDictionaryBuilder.h
3.GAIEcommerceFields.h
4.GAIEcommerceProduct.h
5.GAIEcommerceProductAction.h
6.GAIEcommercePromotion.h
7.GAIFields.h
8.GAILogger.h
9.GAITrackedViewController.h
10.GAITracker .h
在我的AppDelegate.h中
#import< UIKit / UIKit.h>
#importGAI.h
@interface AppDelegate:UIResponder< UIApplicationDelegate>
@property(strong,nonatomic)id< GAITracker>跟踪器;
@property(强,非原子)UIWindow *窗口;
@end
在我的AppDelegate.m文件中
#importGAIDictionaryBuilder.h
#importAppDelegate.h
#importGAI。 h
#importGAIFields.h
/ ** Google Analytics配置常量** /
static NSString * const kGaPropertyId = @UA-000000-1; //占位符属性ID。
static NSString * const kTrackingPreferenceKey = @allowTracking;
static BOOL const kGaDryRun = NO;
static int const kGaDispatchPeriod = 30;
@interface AppDelegate()
@end
@implementation AppDelegate
$ b $ - (void)applicationDidBecomeActive:(UIApplication *)application {
[GAI sharedInstance] .optOut =
![[NSUserDefaults standardUserDefaults] boolForKey:kTrackingPreferenceKey];
$ b - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//在应用程序启动后执行其他定制工作
//然后初始化Google Analytics。
[self initializeGoogleAnalytics];
返回YES;
}
- (void)initializeGoogleAnalytics {
[[GAI sharedInstance] setDispatchInterval:kGaDispatchPeriod];
[[GAI sharedInstance] setDryRun:kGaDryRun];
self.tracker = [[GAI sharedInstance] trackerWithTrackingId:kGaPropertyId];
}
在我的ViewController.h中
#import< UIKit / UIKit.h>
@interface ViewController:UIViewController
@end
在我的ViewController.m中
$ p $ #importViewController.h
#importGAI.h
#importGAIFields.h
#importGAITracker.h
#importGAIDictionaryBuilder.h
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//加载视图后通常从笔尖执行任何其他设置。
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
//处理任何可以重新创建的资源。
}
- (void)viewDidAppear {
//此屏幕名称值将保持设置在跟踪器上,并以
//发送,直到它被设置为新值或到零。
[[GAI sharedInstance] .defaultTracker set:kGAIScreenName
value:@Home Screen];
//发送屏幕视图。
//以前的V3 SDK版本。
// [[GAI sharedInstance] .defaultTracker
// send:[[GAIDictionaryBuilder createAppView] build]];
// SDK版本3.08及以上。
[[GAI sharedInstance] .defaultTracker
send:[[GAIDictionaryBuilder createScreenView] build]];
}
无法将屏幕名称发送到Google Analytics(分析)请帮助我...
使用这一个用于 viewdidload
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
id< GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName value:kBookingConfirmation];
[tracker send:[[GAIDictionaryBuilder createAppView] build]];
}
I created sample project and added google analytics based on google tutorial. But when i run this app, i couldn't see any hits sending from app.
I have added all these libraries
1.libsqlite3.0.tbd
2.libGoogleAnalyticsServices.a
3.libsqlite3.dylib
4.libz.dylibs
5.CoreData.framework
6.SystemConfiguration.framework
Added these library file too
1.GAI.h
2.GAIDictionaryBuilder.h
3.GAIEcommerceFields.h
4.GAIEcommerceProduct.h
5.GAIEcommerceProductAction.h
6.GAIEcommercePromotion.h
7.GAIFields.h
8.GAILogger.h
9.GAITrackedViewController.h
10.GAITracker.h
In my AppDelegate.h
#import <UIKit/UIKit.h>
#import "GAI.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) id<GAITracker> tracker;
@property (strong, nonatomic) UIWindow *window;
@end
In my AppDelegate.m file
#import "GAIDictionaryBuilder.h"
#import "AppDelegate.h"
#import "GAI.h"
#import "GAIFields.h"
/** Google Analytics configuration constants **/
static NSString *const kGaPropertyId = @"UA-000000-1"; // Placeholder property ID.
static NSString *const kTrackingPreferenceKey = @"allowTracking";
static BOOL const kGaDryRun = NO;
static int const kGaDispatchPeriod = 30;
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)applicationDidBecomeActive:(UIApplication *)application {
[GAI sharedInstance].optOut =
![[NSUserDefaults standardUserDefaults] boolForKey:kTrackingPreferenceKey];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Do other work for customization after application launch
// then initialize Google Analytics.
[self initializeGoogleAnalytics];
return YES;
}
- (void)initializeGoogleAnalytics {
[[GAI sharedInstance] setDispatchInterval:kGaDispatchPeriod];
[[GAI sharedInstance] setDryRun:kGaDryRun];
self.tracker = [[GAI sharedInstance] trackerWithTrackingId:kGaPropertyId];
}
In my ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
In my ViewController.m
#import "ViewController.h"
#import "GAI.h"
#import "GAIFields.h"
#import "GAITracker.h"
#import "GAIDictionaryBuilder.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewDidAppear {
// 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.
[[GAI sharedInstance].defaultTracker set:kGAIScreenName
value:@"Home Screen"];
// Send the screen view.
// Previous V3 SDK versions.
// [[GAI sharedInstance].defaultTracker
// send:[[GAIDictionaryBuilder createAppView] build]];
// SDK Version 3.08 and up.
[[GAI sharedInstance].defaultTracker
send:[[GAIDictionaryBuilder createScreenView] build]];
}
am not able to send screen name to google analytics pls help me...
use this one for viewdidload
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName value:kBookingConfirmation];
[tracker send:[[GAIDictionaryBuilder createAppView] build]];
}
这篇关于谷歌分析不在iOS中发送任何匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!