Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 30    Views: 117

shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
02/10/13 07:14 AM (12 years ago)

What files to put Flurry code in...

Hi, I've put Flurry analytics code in my app, but I want to add a few more of their features which are just a couple lines of code you can copy into your Xcode project for each feature. I was wondering if anyone knows which file you are supposed to copy and paste the code into. Some of the features I was thinking of putting in is on the Flurry instructions, which I have pasted a link to below. If you scroll to steps 3 and 4, they have optional code to add in and that's what I am wondering about where to put the code in. Thanks, David link: https://www.dropbox.com/s/hd26guv4zxkdqt9/FlurryAnalytics-READMEv4.x.pdf
 
ceerup
Code is Art
Profile
Posts: 1033
Reg: Oct 10, 2011
New York City
16,380
like
02/10/13 09:47 AM (12 years ago)
i believe you put it in the screen where you want it to show, or the app_delegate.m file
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
02/10/13 10:09 AM (12 years ago)
So if i want it for my entire app and not a specific screen, I should put it in the appdelegate.m? Also would I need to put it in the appdelegate.h file?
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/10/13 10:16 AM (12 years ago)
To track user behavior you need to put that code in each screen you want to track. For instance if you put the first code in your customUrl screen it will track how many ties that screen is used. You can also track specific rules using the dynamic variable option. You'll need some extra programming to make that work. Hope this helps.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/10/13 10:17 AM (12 years ago)
Sorry. Not 'rules' but 'URLs' - dang auto correct.
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
02/10/13 10:23 AM (12 years ago)
So if I have a bunch of RSS feeds, and I want to see what is used the most of all the feeds, I need to add that code into the rss.m file and then add the link to each RSS feed?
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/10/13 11:01 AM (12 years ago)
Correct. You'd need to set up a variable that would be either the RSS feed title or the actual URL. Then that variable would be the dynamic variable that flurry needs for reporting. You'd do this just before the call that launches the RSS feed. I haven't actually done this with flurry, but did it with Socialize and it's the same basic principle.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/10/13 11:06 AM (12 years ago)
I'm not at my computer so I can't send you code, but if you look at my second post in this thread it should give you what you need, I've set up a shareTitle variable. You can do something similar for flurry. http://www.buzztouch.com/forum/thread.php?tid=9D3C1A8F62FA80AD84FA327&command=isSearching&currentPage=1&topicTitle=socialize&createdBy=&repliedBy=&minViews=-1&maxViews=-1&minReplies=-1&maxReplies=-1&forumCategory=
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
02/10/13 11:19 AM (12 years ago)
Forgive me, I don't know a lot about code. Do I just copy the code you have in that second post (with the exception of the socialize part at the very end) and then in each of the places it says "TITLE," I should replace it with the title of my RSS feed? Also one more thing- where in the rss.m file would I need to put this, or does it not matter? Thanks again so much, David
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/10/13 02:28 PM (12 years ago)
You could try this. I haven't tried it, but seems to me it should work. In the BT_screen_webview.m file located in the bt_screen_rssReader directory, find the section that begins with: /* Where is the file? Just before that section, insert the following code: NSString *shareTitle = [[NSString alloc] init]; NSData *htmlFile = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:useURL]]; NSString *htmlString = [[NSString alloc] initWithData:htmlFile encoding:NSUTF8StringEncoding]; NSArray *substrings = [[NSArray alloc] init]; substrings = [htmlString componentsSeparatedByString:@"<TITLE>"]; if ([substrings count] < 2) { substrings = [htmlString componentsSeparatedByString:@"<title>"]; } if ([substrings count] > 1) { NSString *rightPart = [substrings objectAtIndex:1]; substrings = [rightPart componentsSeparatedByString:@"</TITLE>"]; if ([substrings count] < 2) { substrings = [rightPart componentsSeparatedByString:@"</title>"]; if ([substrings count] < 2) { shareTitle = [NSString stringWithString:useURL]; } else { shareTitle = [substrings objectAtIndex:0]; } } else { shareTitle = [substrings objectAtIndex:0]; } } else { shareTitle = [NSString stringWithString:useURL]; } [Flurry logEvent:@"NEWS ARTICLE" withParameters:shareTitle]; This will log all individual news articles read from the rss feed. Flurry limits you to 100 events so this may not be useful if you have a lot of app use. Give it a shot. You may need to experiment a bit.
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
02/10/13 02:46 PM (12 years ago)
Thanks MGoBlue. Two things: -I found BT_screen_webView.m under the BT_Screens folder. I couldn't find a bt_screen_rssReader directory. Is this the right file? -Also, if I want to view which RSS feeds are being used along with specific custom email screens, etc. do I replace the part of the code you just posted called "NEWS ARTICLE"? David
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/10/13 02:52 PM (12 years ago)
What are you using to pull rss feeds? The "NEWS ARTICLE" can be what ever you want it to be. That's the value you set up to track. You can probably use a variable there to designate which rss feed. This gets complicated but should work. Like I said, you'll need to experiment and see what works and doesn't.
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
02/10/13 05:49 PM (12 years ago)
Awesome, I'll try it out! Just to confirm, it should be under the BT_Screens folder? That's the only place I found a BT_screen_webView.m file. David
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/10/13 05:59 PM (12 years ago)
Where are you pulling your RSS feeds from? What screen? Are you using the rss plugin?
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
02/10/13 06:04 PM (12 years ago)
There are seven or eight different RSS feeds. They're under one menu and the menu is also a tab. I'm using the RSS plugin, but this is a v1.5 app. Thanks, David
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/10/13 06:36 PM (12 years ago)
Ok. a 1.5 app. Haven't used that in a while so I'm not sure which screen to use for sure. Let me know how it goes.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/10/13 06:52 PM (12 years ago)
I just looked at one of my 1.5 apps. I'm thinking you'll want to insert the code I gave you above in the BT_screen_rssReader.m file. Try it just below this section of code: //we must have a dataURL if([[BT_strings getJsonPropertyValue:screenData.jsonVars:@"dataURL":@""] length] > 3){ //look for previously used version... if([BT_fileManager doesLocalFileExist:[self saveAsFileName]]){ [BT_debugger showIt:self:@"using cached version of screen data"]; NSString *staleData = [BT_fileManager readTextFileFromCacheWithEncoding:self.saveAsFileName:-1]; [self parseScreenData:staleData]; }else{ [self downloadData]; }
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
02/10/13 07:05 PM (12 years ago)
Are you talking about the appdelegate.m file? I don't see that in the BT_screen_rssReader.m file but "//we must have a dataURL" and the rest of that is in the appdelegate.m file. David
 
Kaybee
buzztouch Evangelist
Profile
Posts: 659
Reg: Sep 22, 2012
Perth, Australi...
44,690
like
02/10/13 07:47 PM (12 years ago)
ahhh, MGoBlue, How would I track multiple HTML pages using flurry events? Because I would put in the code from flurry in teh HTMLDoc.m just after teh viewDidLoad, but that would mean than any HTMLDoc page would signal an event and i wouldn't be able to determine which pages are being viewed, is there a way around this? Cheers
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/10/13 08:01 PM (12 years ago)
The same general approach works. Each HTML page has a title and URL. The key is to find the spot where the BT plugin finds the URL then use the code to extract the title for tracking. If I get back to my computer tonight I'll check to see if my code in te HTML plugin is the same. Again, this is all my theory based on what I've done with Socializr. Please post if you gt it working.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/10/13 08:03 PM (12 years ago)
David - I pulled that code from the BT_screen_rssReader.m file in one of my 1.5 apps.
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
02/11/13 04:44 AM (12 years ago)
Hmmm, do you think it will make any difference if it's in the appdelegate.m because that's the only place I see that and it's that entire section of code.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/11/13 06:51 AM (12 years ago)
If you want to track specific events, it needs to be in the screen for those events. The main flurry activation code goes in the app delegate because that applies to the entire app.
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
02/11/13 07:37 PM (12 years ago)
So if the code you said to look for before isn't in my rssreader.m file, is something wrong with my code?
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/11/13 07:45 PM (12 years ago)
Are you sure you've got a version 1.5 app? I just downloaded fresh 1.5 source code, opened the BT_screen_rssReader.m file and searched for '//we must have a dataURL' and found the exact block of code I listed above. Either you don't have a 1.5 app or you're not looking in the right place. Not sure what to tell you.
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
02/11/13 08:03 PM (12 years ago)
Okay, I kind of found out the problem. It's a really long, confusing story but I messed some code up when I was playing around with stuff last week but I copied over the normal rss_reader.m code over from another project I didn't mess around with (and replaced all of the references to that project name with this project name) so now it's the right code (I totally understand if that sounds extremely confusing)... but when I ran it in the simulator I got: Mach-O Linker Error Linker command failed with exit code 1 (use -v to see invocation) Have you seen this before?
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/11/13 08:23 PM (12 years ago)
Yes, that makes perfect sense. I've done the same thing before. The linker error could be a missing framework. There is probably a bit more description of the error. If you click on the error in the window on the left it should show you more description on the right (does that make sense?). It could also be that you didn't drag Flurry/libFlurry.a into your project.
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
02/11/13 08:28 PM (12 years ago)
Just messaged you a screenshot of the error. Thanks again, David
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
02/12/13 07:01 AM (12 years ago)
David - I sent you a message regarding the error you're getting. For the flurry code, I think the following should work. Unfortunately, it takes a while for flurry to report the activity, so I have no way of knowing for sure, but it seems to work and it doesn't error out. In your BT_screen_rssReader.m file, first add the #import "Flurry.h" statement. Then, find the following section of code: //build a BT_screen_webView to load. Give it an itemId that matches the menuItems //loadScreenWithItemId value so we BT_viewControllManager can find it. NSString *theDynamicScreenItemId = [thisMenuItem itemId]; Directly below that, add the following: //flurry analytics [Flurry logEvent:theDynamicScreenItemId];
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
04/09/13 01:06 PM (12 years ago)
MGoBlue - i've gotten logevents working and reporting in Flurry, but am having difficulty figuring out where to use [FlurryAPI logAllPageViews:navigationController] in my BT 2.0 app. My app's main menu is a simple list menu which call other list menus. Will this logAllPageViews help me automatically log when these other pages load? If you have any guidance on where/inject this into my BT code I would greately appreciate it.
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
04/09/13 01:35 PM (12 years ago)
I see in the Flurry.h file, the note that says: "Please make sure you assign the Tab and Navigation controllers to the view controllers before passing them to this method." Think this is what I'm asking how to do, for a BT 2.0 app that uses list menus.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.