noahsw / google-analytics-sdk-for-osx

Track usage of OS X applications
MIT License
56 stars 9 forks source link

Documentation/Examples #1

Closed stephenlind closed 11 years ago

stephenlind commented 11 years ago

I've implemented the Google Analytics API in my iOS app, would love to test your SDK out in an OS X app. Do you have any code examples for how it's intended to be used?

I am a little confused because it does not seem to have the same Screen/Tracker structure as the iOS SDK. Even an example unit test would be helpful.

I'd be willing to assist by helping with documentation/examples/whatever.

noahsw commented 11 years ago

Thanks for the interest Stephen. You're right -- I should add some code samples. If you could help me, that'd be great.

Calling the library is really simple. This is the method you want:

AnalyticsHelper -- fireEvent: (NSString*)eventAction eventValue:(NSNumber*)eventValue

So something like this:

 [AnalyticsHelper fireEvent:@"App load count" eventValue:5]

I also just realized my site's URL is hard coded into that method. That should definitely be removed ;-)

stephenlind commented 11 years ago

I spent some more time playing with different OS X analytics solutions.

With your solution, unfortunately, I kept getting no response from the URL request to google (failure) which makes me think there is an issue with the constructed URL.

I did find this project, though, and so far it is working for me; the app successfully masquerades as a mobile app.

https://github.com/Coppertino/AnalyticEverything

noahsw commented 11 years ago

Hmm... can you paste in the constructed URL and the method you're calling? I use this library in my production app and it's been tracking things just fine.

naorcho commented 11 years ago

I added as a reference the workspace and then tried to call [AnalyticsHelper fireEvent:@"App load count" eventValue:5]

but how should I import the library? Please post some more info, or upload an example project.

stephenlind commented 11 years ago

Sorry for a very slow response. I gave this library another try, it still does not seem to be actually getting to google (according to the real-time usage). I'm using an iOS app analytics profile, not a web one.

http://www.google-analytics.com/__utm.gif?utmt=event&utmhid=994326472&utmip=213.35.159.130&utmje=0&utmdt=&utmsc=-&utmul=-&utmr=-&utmsr=-&gaq=1&utmfl=-&utmcs=UTF-8&utmp=/&utmcc=__utma=0.13354765.1378372265.1378372265.1378372265.2%3B+__utmz=0.1378372265.1.1.utmcsr=(direct)%7Cutmccn=(direct)%7Cutmcmd=(none)%3B&utmn=431169405&utmhn=&utmni=1&utmac=UA-41476611-1&utme=5(Mac%201.0*Launch*46FF3A8B-CBB4-46E6-B1F9-D4D730352331)(0)&utmwv=5.2.2d&

In order to get to this place, I did not use the framework, but rather copied the source files to my own project. This is because I couldn't figure out how to import AnalyticsHelper.h in order to use it (you don't have any public headers, even after I attempted to make AnalyticsHelper.h a public header, it still wouldn't import).

Admittedly, I am not very experienced with building 3rd party Objective-C frameworks outside of cocoapods into my projects, but I suspect there may be something actually missing here.

By the way, I stopped using the AnalyticEverything framework (mentioned above) because it was causing crashes :). If I can get this to work I'd be happy to help with posting an example app.

Thanks for any assistance!

noahsw commented 11 years ago

Hey Stephen -- I also apologise for the slow response. I had some moments of inspiration today and put together a sample project that demonstrates how to interface with the SDK. Take a look and let me know if it helps.

I haven't changed anything with regards to the URL that gets sent to Google. If you're still not seeing your events show up, I'll have to do some digging. But like I said before, I have an app in production that uses this and the events show up just fine.