I just started using this and it’s fantastic. Thanks Jon!
Awsome! Thanks 
I have gone live with it and it works well except there are some mobile devices not sending user agent.

So I’m going to try the user agent work around in all cases, not only iOS and see if it will be better and update the code if so.
— EDIT : this post and question is no longer valid, data shows up now… seems like it doesn’t track anything from windows simulator, but once I ran it on any device, it started showing up in Analytics dashboard —
Hi Jon,
I created my account on google analytics yesterday (a Mobile App type property), and today I’m trying to get it working in my app using your module.
So far however, I’ve had no luck: no matter what I do, the google analytics console shows me “0 sessions” in Realtime tracking overview.
Is this an error, should it work? Or does your module not give GA the realtime data and I’m just over-concerned? From other apps (fully native professional apps, not corona based) I know the realtime data are usually displayed within 5-10 seconds as soon as I run the app
Here’s the bit of your code I have in my main.lua (I obviously replaced the tracking codes with Xs, but in my code I have the right IDs - checked it about a hundred times.
print("\n\n---------START GOOGLE ANALYTICS PRINTOUT-----------") local ga = require("GoogleAnalytics.ga") ga.init({ isLive = false, testTrackingID = "UA-xxxxxxxx-1", -- \<-- Replace with your tracking code. If code is wrong it fails silently. productionTrackingID = "UA-xxxxxxxx-2", -- \<-- Replace with your tracking code. If code is wrong it fails silently. debug = true, appName = "TSC Calc Test", appVersion = "1.1.4", appID = "com.mcxondev.tsccalc.test", clientID = "CoronaSimulator-" .. math.random( 1,100000) }) ga.enterScene("Main Scene (start app)") print("---------END GOOGLE ANALYTICS PRINTOUT-----------\n\n")
I’m also attaching my terminal output screenshot and the sad view of the google analytics console.
Any tips on what am I doing wrong?
I appreciate any advice you can give me.
Thank you.
Hi Joe,
yes it only takes a couple of secs to show up in the real time stats.
To debug this you can copy the URL you see in the debug console and use it in a browser, it should show up as a hit in real time stats.
Paste a copy of the URL here and I’ll test it with my test ID as well.
Well no worries, like I said in the edit on top of my post - it only doesn’t work in the windows simulator, but when I ran the same build on a device, the analytics are showing up in realtime.
… except on my older HTC Desire S phone :)
I Don’t know why, I tested 7 different devices, and every single one of them reports ok, but the HTC phone I have with a custom (but HTC based) ROM doesn’t seem to send anything - or at least it doesn’t show up in analytics at all, realtime, or the historical (previous day for now)
I’m trying to get some more HTC devices to try if it’s just this one, or if it’s a HTC linked problem.
weird though…
That is weird! It’s just a POST network request. Very basic stuff, should just work everywhere one would think 
This is great, thanks jonjonsson!
My client is asking me to implement Google Tag Manager tracking into a corona app. Any ideas on how that could be done?
This looks promising. What happens if the user doesn’t have internet? Does it give an error?
No there is no error. Offline events are stored in memory. If the app goes online these events are sent. If the app is released from OS memory the events are lost.
Excellent. I’m in the process of incoroporating it now but I have a question. If you leave the isLive as false, will it record events?
I’m trying to test it and I know it takes some time for the results to appear in Google but I wanted to make sure that I’m actually SENDING events.
In the previewer I’m getting some errors, but I assume that’s because it’s not on a device.
If you leave the isLive as false, will it record events?
Yes but on your testTrackingID. You can see real time analytics within few seconds.
In the previewer I’m getting some errors, but I assume that’s because it’s not on a device.
Events are tracked on simulator just as it were a real device (but only on testTrackingID, even if isLive = true).
What kind of errors?
I got it working! Looks like it was an ID 10 T error.
But I have another question. How can I specify screens? I see in Google analytics that it tracks screens, but how do I tell it when it’s hit a new screen?
Thanks! This REALLY helps me!
You use:
ga.enterScene("my screen name")
So with composer you could do:
[lua]function scene:show( event )
if ( phase == “will” ) then
elseif ( phase == “did” ) then
ga.enterScene(“my screen name”) – or ga.enterScene(composer.getSceneName( “current” ))
end
end[/lua]
oh well. thats why my device is not working.
is there any patch yet ?
No, I tried user agent work around for Android as well and still have missing device names. The biggest offender is HTC One according to my stats (but not all version though).
I added secondary dimension variable with the Device name from Corona so I can see what these (no set) devices are.
[lua]sessionParams = {cd1 = system.getInfo(“model”)}[/lua]
Here are the offenders:
1705B 4.1.1
306SH 4.4.2
A0001 4.4.4
A5Smiley 4.4.2
AllviewAX2Frenzy 4.0.4
D6653 4.4.4
FS-M787S 4.0.4
Full Android on Crespo4G 4.1.1
GT-I9507 4.3
HTC One_M8 4.4.2
HTC One_M8 4.4.3
HTC One_M8 4.4.4
HTC One_M8 5.0
HTC One_M8 5.0.1
HTC6515LVW 4.4.2
Informer 701 4.0.3
iris400Q 4.4.2
iris700 4.4.2
Lenovo A706_ROW 4.1.2
LG-D852 4.4.2
LGL39C 4.1.2
LGLS620 4.4.2
LGLS660 4.4.2
LGLS990 4.4.2
Micromax A082 4.4.2
MyPhone Agua Rain 3G 4.2.2
Nexus 7 L
Nexus 9 5.0
NX008HD8G 4.1.1
One 4.4.4
Pacific800i 4.2.2
QTAQZ3 4.4.2
Samsung Galaxy S3 - 4.3 - API 18 - 720x1280 4.3
SM-G313HZ 4.4.2
SM-N910F 4.4.4
SM-N910P 4.4.4
SM-N910T 4.4.4
Smartfren Andromax AD6B1H 4.4.2
Studio 5.0LTE 4.3
Telenor Smart Pro 2 4.1.1
TP7-1000DC 4.1.1
XT1039 4.4.4
XT1254 4.4.4
XT830C 4.4.4
Thanks for the update jonjonsson 
my device is Nexus 5.
so meanwhile i use other device to test it ?
thanks
Ah ok, we are not talking about the same thing 
The module works with ALL devices, even simulator. Just the device name is not reported in few cases.
If you are having problem getting it to work start with simulator only and a test tracking ID. Then go to Google Analytics for your test ID and click “Real time” and you should see a connection. If not something is misconfigured.
Oh … sorry. my bad. so its about reporting ?
i have check in simulator, all worked, but when i test in analytic realtime, no device active. thats why im asking.
heres my setting. im using composer
-----------analytic google
ga = require(“GoogleAnalytics.ga”)
ga.init({ – Only initialize once, not in every file
isLive = true, – REQUIRED
productionTrackingID = “UA-xxxxxx-2”,
testTrackingID = “UA-xxxxxxx-2”, – REQUIRED Tracking ID from Google
debug = true, – Recomended when starting
})
and heres event tracker in other lua files
function onmoreappstouch( self, event )
if event.phase == “ended” or event.phase == “cancelled” then
ga.enterScene(“more series”)
audio.play( slide_audio, { channel=0, loops=0, fadein=100 } )
composer.gotoScene( “moreapps”, { effect = “slideLeft”, time = 1200 } )
else
return true – indicates successful touch
end
end
Because you have isLive = true the device will use the productionTrackingID and you are probably checking the testTrackingID in Google Analytics.
It works for you in the simulator because simulator ignores isLive. Simulator is only used for developing and always uses testTrackingID.
So for now, put isLive = false and just focus on the testTrackingID. It will work on device also.
When you are close to going live, create your productionTrackingID, change isLive = true and test on device. That way your test data is not mixed with live data in Google Analytics.
I already use false in previous version and its not working. That’s why I try to switch in true. Or is there any thing I missed in Google setup?