Copy link to clipboard
Copied
Hello,
I'm using Google Measurement Protocol to collect analytics data from mobile Air application
https://developers.google.com/analytics/devguides/collection/protocol/v1/
I found that Air application running on iPad 3 not detecting device model in google analytics reports.
I guess it's because Air environment sending incomplete user-agent string.
This is what it sending:
Mozilla/5.0 (iOS; U; ru) AppleWebKit/533.19.4 (KHTML, like Gecko) AdobeAIR/3.1
And this user-agent string sending by Safari on ipad (for comparison😞
Mozilla/5.0 (iPad; CPU OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8536.25
So Air application knows much less than Safari.
My question is: How to create custom user-agent string in Air application so it contains enough data for google analytics to detect device model?
Is there any solution that will work on most ios and android devices?
Copy link to clipboard
Copied
are you using sytem.Capabilities to detect device infos?
Copy link to clipboard
Copied
Not yet.
But looks like I should.
I think I will use sytem.Capabilities to guess device model and set appropriate user-agent string from list.
But how many devices I can detect using this way? Can I detect ipad 1, 2, 3, 4?
Copy link to clipboard
Copied
But how many devices I can detect using this way? Can I detect ipad 1, 2, 3, 4?
How about trying out?
Copy link to clipboard
Copied
Hello
I have tried implementing the google measurement protocol without success.
Despite the fact that I get the code 200 from the url request, nothing appears on the dashboard.
I have tried using different parameters following the google guidelines, but that does not change anything.
Of course I have verified the used account and that the parameters code are correctly indicated.
Any help would be greatly appreciated....
Copy link to clipboard
Copied
I don't know if you managed to make it work, but it kind of worked for me, I did this:
var _urlReq:URLRequest = new URLRequest('http://www.google-analytics.com/collect');
var uuid:String = 'my-generated-uuid';
_urlReq.method = URLRequestMethod.POST;
var scName:String = '&v=1&tid='+myTrackingCode+'&cid='+uuid+'&an='+myAppName+'&av=1.0&t=appview&cd='+myScreenName;
_urlReq.data = scName;
var urlLoader: URLLoader = new URLLoader();
urlLoader.load(_urlReq);
I say "it kind of worked" because I haven't been able to send custom events yet, butI'm on the right track.
Copy link to clipboard
Copied
FYI, the POST method works from AIR, but fails from a browser because of cross-site-scripting rules. I resolved this here:
Copy link to clipboard
Copied
Hey did you ever get the Event tracking sorted?
Copy link to clipboard
Copied
Yeah, I did this:
var eventPayload:String = "v=1&tid="+GACode+"&cid=255&an="+appName+"&av=1.5.0&t=event&ec="+var1+"&ea="+var2+"&ev=1";
var1 and var2 are my device identifiers and screen identifier, but those are the values I decided to send, hopefully the string will give you and idea of how to begin. I haven't tried the Zwetan analytics library yet, but I guess it would be easier.
Copy link to clipboard
Copied
well it's not so much the "zwetan" library lol it's an implementation of the measurement protocol
by default google analytics will use the user-agent to determine the device
and the measurement protocol allow to override the user-agent which technically allow you to change the device.
see here ua parameter
But google warns about providing hand-crafted user-agent, if they don't recognise it they will ignore the request.
From what I tested, it does work, eg. you can send a request from a Linux server with the user-agent of a windows desktop browser and analytics will see the device or operating system as "windows".
For mobile device, it's possible to override too, but then you will have to detect the iPad 3 and have its user-agent ready to use, unlikely you could dynamically generate it.
Copy link to clipboard
Copied
When sending a hit request to the measurement protocol from AIR
the TCP stack will use by default the AIR user-agent
you can override it with the ua parameter
see Measurement Protocol Parameter Reference | Analytics Measurement Protocol | Google Dev...lso
you can also use a library that do that for you
check out as3-universal-analytics v0.8
a Google Universal Analytics implementation for ActionScript 3.0
Release First release v0.8 · zwetan/as3-universal-analytics · GitHub