Google Analytics for Defold

Oh, thank you for reporting! I guess maybe I shouldn’t even bother setting a custom user agent when using HTML5…

1 Like

I’ve released version 1.3 of the library. The new version will not attempt to change the User-Agent on HTML5 builds since this is prevented by all modern browsers.

3 Likes

what kind of analytics should I use. Standard google analytics or firebase?

1 Like

Hmm, I dunno. For Defold you currently have three options:

  1. Defold analytics. This is super easy to setup and use but it doesn’t allow you to track in-game events and user interaction.
  2. Google Analytics. The full suite of Google Analytics at your fingertips. Personally I’m not very fond of their dashboard though. It’s super advanced but I find it hard to get the data in an easy to use format.
  3. Facebook Insights. Send tracking data using facebook.post.event().

The Firebase Analytics dashboard looks really nice, but unfortunately you’ll have to wait for Native Extensions and build your own extension to use it.

2 Likes

I’m asking this because then you create new property in the analytic dashboard it ask you which tracking method to use

Ah, I see. I believe you need to select Google Analytics in that case.

1 Like

There is no Google Analytics SKD in dashboard anymore when you’re creating new property :frowning:
Only Website and Firebase Analytics

Where specifically? I still get the Mobile App and Website options:

Mobile app has no “Google Analytics SKD” options now, Firebase only

But if create a new account then “Tracking ID” still available. Cool.

Tried to use britzl/defold-googleanalytics in project. Registered new analytics account, got Track ID number, sent events but nothing happing in GA. Google Analytics not register any requests. I guess they changed the algorithm for new account to Firebase. @britzl would you check the lib with a new account id? Also I asked @AGulev for check lib with his Id, he said that the lib works with old Id but not with new".

This is the important part. The Google Analytics Measurement Protocol is still very much a supported Google product. I would be surprised if it’s retired anytime soon.

still available, but not working for a new project. Just try to create a new account.

I just created a new account and a new Defold project and immediately see Real Time results in Google Analytics when using the Google Analytics for Defold library.

1 Like

sorry, it was a bit weird, I just looked GA dashboard today and all works fine! :confused:

2 Likes

I have issues with setting up GoogleAnalytics in my project, I tried to use different: created new Properties as web, as mobile, and as mobile-web. no see real-time updates… tested in Defold Editor, as web-build too. tried also to create via new account. zero result.

tracking ID is added to game.project settings.

[EDIT]: works now. thanks @AGulev , looks like I missed: ga.update() and need to wait some time to start working stats.

{EDIT2]: I found what I missed first time, be sure to send at least some statistics, for example: ga.get_default_tracker().screenview("menu") without it will no work.

4 Likes

Google change there google analytics console. To make this project work, you need to get universal analytics id.
UA-XXXXXXXXX-X

I make screenshots, how it looks now.
1)You need create new property
2)Choose universal analytics property
3)Tracking id should start with UA-

7 Likes

Hi everyone

Universal Analytics shutdown late October and was replaced Google Analytics 4. I’ve tried the extension against a new web property but got no event in the Realtime reports.

Did anyone managed to make it work with GA4?

Is there a classic REST API for GA4? I think I did research this a while back, but couldn’t find any info.

I believe there is no REST api, although I’m not 100% sure. This is an alternative way to make GA4 work though:

  • include the GA4 script tag in the main/engine_template.html. Should look something like this:

       <!-- Google tag (gtag.js) -->
      <script async src="https://www.googletagmanager.com/gtag/js?id=<custom_id>"></script>
      <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());
    
        gtag('config', '<custom_id>');
      </script>
      <!-- end Google tag (gtag.js) -->
    
  • send any event to GA4 by calling the gtag() function

-- send ga4 event from browser 
	if (sys.get_sys_info().system_name == 'HTML5') then
		html5.run("gtag('event', '<event_name>', {<event_params>})")
	end

That works for the browser apps. Haven’t checked a solution for the the native apps yet.