AttackPattern / CSharpAnalytics

Google Analytics for Windows 8, Windows Phone & desktop applications
142 stars 36 forks source link

Google analytics application properties do not show data #1

Closed kpantos closed 11 years ago

kpantos commented 11 years ago

Hi, I'm trying to use your library for a windows 8 app I'm developing. I followed your instructions and integrated CSharpAnalytics to my project. I can now see get requests going to google analytics (using fiddler) and also see your Debug Info on my output window when debugging. Everything seams to be working but unfortunately I can't see any data on Google analytics dashboard. Am I doing something wrong?

Stefan-deHoDev commented 11 years ago

I'm having the same problem. It seems that this does not work when the google analytics property is set to "app". Although the description linked in the readme tells us to create an "app" analytics property. (I didn't test any other google analytics properties)

I have had the same issue with every other google analytics framework/project. None seem to work with an "app" analytics property.

PS: I used the sample project included in the download to test this, with the only change being replacing the property id with mine. I tested it last week and the property was created a week before the test, so it can't be a delay problem

kpantos commented 11 years ago

You're right. I've changed my property type from "app" to "Website" and it now works. From what I've been reading the "app" property works with posting xml (at least in android sdk) and not by get requests to dummy images in the google analytics engine.

damieng commented 11 years ago

Yes, sorry this is a known issue I should go and put in the README.

All the reverse-engineering I could do/find online was around the web site parameters.

Google have a new Measurement Protocol that is fully documented including for apps but that's currently in closed beta.

In the mean time we can either use websites or try and reverse engineer the Android/iOS calls.

damieng commented 11 years ago

I just setup an Android VM and added some simple tracking from Google's latest API. It looks like they are already using the Measurement Protocol in these SDK's even though there is no mention about signing up for the closed beta. It's possible it's beta only for web sites.

I'll take a look at adding support for the new Measurement API in the next few days.

Stefan-deHoDev commented 11 years ago

You're right. I have 2 google analytics app properties. One was accepted for the closed beta, the other is a normal app property not in the Measurement Protocol beta. However I can use the Measurement Protocol for both without problem and it works great, real-time data with maybe 5 seconds delay. This is the code I used (just replace the xxxxxx with your app property id and you'll get live data)

String payload = "v=1&tid=xxxxxxxxxxxx&cid=1234&t=appview&an=protocoltest&av=0.0.0.1&cd=PostNormalProp";
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (PC; en-us) Windows 8 (KHTML) App");
Print("UserAgent: " + client.DefaultRequestHeaders.UserAgent.ToString());
var get = await client.PostAsync(url, getcontent(payload));
Print("Result Post Normal: " + await get.Content.ReadAsStringAsync());

Edit: Note that the user agent does not seem to be in the correct format to report device type/data and os version. Should any of you find the right format to report these, I would appreciate a comment

damieng commented 11 years ago

Hmm, so it looks like they're putting a handful of the new protocol parameters onto the old UTM tracker. That's easy to add. I have some code to access device manuf and version but I don't think that should go in the user agent. Getting the OS version would require a WinRT component.

Stefan-deHoDev commented 11 years ago

I was not asking for something like that. However Google Analytics has device models, os version and so on integrated and I would like to use it (and I guess others would too). I personally would just give the user the option to set all those parameters before they start tracking.

Google Analytics uses the user-agent to get browser, browser version, platform and platform version for websites. Since there is no other way to report these things for apps, I think it's used for device model etc. in app properties.

From the reference:

user_agent_string – Is a formatted user agent string that is used to compute the following dimensions: browser, platform, and mobile capabilities. If this value is not set, the data above will not be computed.

The last sentence is not 100% true. In my tests my "appviews" were being computed even with no user-agent set.

damieng commented 11 years ago

Basic measurement protocol support is now in the measurement-protocol branch and it is recording real-time against application types. Need to add tests before I merge it back into master.

damieng commented 11 years ago

Measurement Protocol support appears to be working and is available for testing. Use the AutoMeasurement class instead of AutoAnalytics as a starting point.