How to set Page Title in Google Analytics for iOS?
I'm using the Google Analytics SDK for iOS in my iPhone app. It tracks "pages" just fine, but I need to also track page titles because they show up in my reports as "(not set)" right now. I think this is done automatically for a website, but I can't figure out how to do it in开发者_运维知识库 an app.
The call to Google Analytics SDK is:
[[GANTracker sharedTracker] trackPageview:@"myPage" withError:&error]
Where "myPage" shows up as the page name, but without a page title. Does anyone have any idea how to do this? Maybe a custom variable or something?
Dont know if i understand you right, but you can only set the page-name cause inside the web you have a page-url and a page-title which is automatically read by google analytics. Inside the ios you only have a page-name or title. So just set your Title of your view, or an internal ios url for the pagename, which you can then identify inside google analytics.
I use google analytics inside my viewWillAppear method of the UITableViewController (you have to set the title, cause otherwise it will be nil) with this code:
[[GANTracker sharedTracker] trackPageview:[self.title] withError:&error]
other idea is just to use the name of the class if they are unique or perhaps the name of the xib loaded with the view:
[[GANTracker sharedTracker] trackPageview:NSStringFromClass([self class]) withError:&error]
Set the name of the View with this line, placed in your viewDidLoad.
self.trackedViewName = @"Main App View";
精彩评论