User Agent and Google Analytics

I am working on integrating Google Analytics with my Corona app, using Google’s rest API (Google Analytics Measurement Protocol).  Everything seems to be cruising along except that my iOS builds aren’t registering as mobile devices in the analytics reporting.  The page views and events register, they just show up with the OS/Browser name being the name of the app.   Android builds show up perfectly.  They show up with the device type I would expect.  I’ve used the Corona SDK Flurry library in the past and things worked great for both iOS and Android.  I’m wondering if the Flurry library has to manually set the user-agent or if there is some special handling of OS/Device info as it’s passed to Flurry?

Any help would be appreciated.

Thanks,

Jeremy

I’m interested in getting this going too, as Google Analytics can give us lots more information than flurry can.

@jeremy06, would you mind sharing some of the code that you’re using to do this? Perhaps we could help in working out what’s not working, or working towards a library for others to use. 

Thanks

Mateo

Mateo,

I haven’t extracted a library for Google Analytics yet, so there isn’t much code to share.  It’s a basic http request with parameters filled in from:

https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters?hl=en-US

 

If I get a response from either the Corona people or Google on this matter, I’ll post more information.  So far I’ve gotten no response.

  • Jeremy

I’m interested in getting this going too, as Google Analytics can give us lots more information than flurry can.

@jeremy06, would you mind sharing some of the code that you’re using to do this? Perhaps we could help in working out what’s not working, or working towards a library for others to use. 

Thanks

Mateo

Mateo,

I haven’t extracted a library for Google Analytics yet, so there isn’t much code to share.  It’s a basic http request with parameters filled in from:

https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters?hl=en-US

 

If I get a response from either the Corona people or Google on this matter, I’ll post more information.  So far I’ve gotten no response.

  • Jeremy

I am also wondering how to tell device model name with Google AnalyticsMeasurement Protocol? 

I am also wondering how to tell device model name with Google AnalyticsMeasurement Protocol? 

Of course, if you ended up here, and you do want this feature to happen, you should vote for it at: http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3584678-integration-with-google-analytics

Of course, if you ended up here, and you do want this feature to happen, you should vote for it at: http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3584678-integration-with-google-analytics

Jeremy, are you willing to share a snippit of your lua code showing how you send the HTTP request to Google Analytics?  Thanks!
Brian

mediakube, 

To post a scene view I use a basic network.request post with a url like the following:

http://google-analytics.com/collect?v=1&tid=UA-XXXXXXXX-X&cid=XXXXXXX&t=pageview&dp=%2Fapp%2Fhome&dt=Home&ul=en_US

You’ll need to use your own tid value.  You’ll need to generate your own cid for each client.

I had to set up my Google Analytics property as a web site because it requires Universal Analytics.  A bit of a hack, recommended by Google.

The other gotcha is if you include parameters in the url that Google doesn’t recognize as part of that particular call type (t parameter) it fails silently.  That’s a joy to figure out.

Hope that helps some.

Wonderful, thanks Jeremy!

Jeremy, are you willing to share a snippit of your lua code showing how you send the HTTP request to Google Analytics?  Thanks!
Brian

mediakube, 

To post a scene view I use a basic network.request post with a url like the following:

http://google-analytics.com/collect?v=1&tid=UA-XXXXXXXX-X&cid=XXXXXXX&t=pageview&dp=%2Fapp%2Fhome&dt=Home&ul=en_US

You’ll need to use your own tid value.  You’ll need to generate your own cid for each client.

I had to set up my Google Analytics property as a web site because it requires Universal Analytics.  A bit of a hack, recommended by Google.

The other gotcha is if you include parameters in the url that Google doesn’t recognize as part of that particular call type (t parameter) it fails silently.  That’s a joy to figure out.

Hope that helps some.

Wonderful, thanks Jeremy!

Hi Jeremy,

Have you any updates or info on getting GA working in your apps?

What kind of events are you tracking?

Does using GA in this manner offer up geographic data like it would for a website?

Thanks.

@fosforus

I’m using it actively in our app Word Slug that’s been out for a little over a month.  We’re tracking basic page navigation and some extra event data on points scored per play.  Basic stuff to understand how people are using our app.

I’m not 100% convinced that all the data is accurate.  There seems to be considerable disparity between what the stores claim as download numbers, what we actually track as “new” players in our database and what GA registers as “new” vs. returning visitors.  If that data is off it’s hard to know if the other data is 100% accurate.

It does offer geographic data.

Thanks for the quick reply, Jeremy!

From what I can tell, iTunes App Store numbers relate to “downloads” or “installs” of the app. While the GA data might be tracking the “first launch” of the apps while a user is connected to the web, like Flurry does… so there will be a disparity there, though small.

Apple is a little closed about things like how they measure that you can download an app on your iPad and it will be available to use on your iPhone, too, if they use the same app store acct… does each acct count as one download or each device? We’re in the dark, there.

What I’m wondering is if you need to manually build in calls for things like geographic location (on a country or state level) when using GA, or if it is automatically included when you use the Measurement Protocol. My clients will want to know how many users in Belgium are installing vs Italy, for example.

@fosforus

You do not have to pass the geographic location data yourself.  GA will make a best guess (based on cell tower data maybe?).  It seems mostly accurate with occasional oddities that I observed while we were in development and I actually knew where all the players were located.  GA tracks data for country and state.  If you need very accurate data you could use the geolocation and pass the data yourself I believe.

Thanks Jeremy,  That’s what I was looking for!

If I add in GA to my apps, I will post up the lua for others to see.