Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Google Universal Analytics for Unity - Support Thread

Discussion in 'Assets and Asset Store' started by tonic, Sep 25, 2013.

  1. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @amynox, nice to hear you're considering my asset.

    Unity 2020 is supported (in fact, most Unity versions are supported, starting from quite old versions up to all recent releases).

    Real-time report with geo location is available in the Google Analytics interface. It makes a distinction between desktop and mobile platforms. But note that all that functionality comes from Google, not from my asset, so it is always up to Google what they tweak in the GA interface.

    Below you can see two screenshots of the GA Realtime Overview and Locations screens. Analytics hits were submitted using a build made using Unity 2020.3.16f1.

    In the first image you can see orange bar saying 100% users are desktop (for mobile devices it'd show a different color).

    GA_realtime_overview_desktopuser_50pc.png
    GA_realtime_locations_desktopuser_50pc.png
     
  2. Blarp

    Blarp

    Joined:
    May 13, 2014
    Posts:
    269
    1. Yes, I can confirm this.
    2. In Google Analytics under RealTime, it shows this, If you send an event, it's under events. Old data would be under Behavior>Events in Google Analytics.

    This thing is pretty perfect still, does exactly what its suppose to with extremely little effort. Nothing else comes close on the entire internet for a Unity - Google Analytics implementation.
     
  3. 60days

    60days

    Joined:
    Jan 27, 2012
    Posts:
    23
    Hi - I've followed the instructions pretty carefully, but still dont receive results in the realtime view. I've created a UA-only property, added a view set to mobile app and named the same as the app name in the analytics monobehaviour, copied in the UA code to both normal & debug fields and no analytics events are received from the editor, or my webGL build.

    I've done this firing events via both the sample scene, any my own scripts. I'm on the latest LTS (2020.3)

    I've also restarted four times with new GA properties & views in case it was a config error, and also tried GA4 property just in case (With G-XXXXX... format code instead of UA-XXXXXX...).

    If I understand the views correctly, I should see events in the parent property even without a view, right? So just having the right UA should produce some kind of event?

    Edit: I cant receive analytics from the editors, but I've found the SystemInfo example calls do fire from WebGL, but no additional use of sendEventHit works. Heres the code that should be firing (no errors in editor when running this):

    Code (CSharp):
    1.         public void SendEvent(string category, string action, string label = null, int value = -1)
    2.         {
    3.             GoogleUniversalAnalytics gua = GoogleUniversalAnalytics.Instance;
    4.             gua.sendEventHit(category, action, label, value);
    5.         }
    and also this alternate usage I spotted in another example method (using the local initialised gua)

    Code (CSharp):
    1.      public void SendPageView(string name)
    2.         {
    3.             gua.sendAppScreenHit(name);
    4.         }
     
    Last edited: Oct 19, 2021
  4. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @60days!

    I just did a refresher test and can verify that I can see hits in the realtime view from both editor and WebGL build, when using a freshly created tracking property and view.

    But here are a few points to answer your questions and help you get the same result:
    1. Just to clarify, you do need to create and use the specific View for mobile app data. At least from past experience, GA seems to filter between the two types of hits, and the hits coming from GUA asset should fall in the mobile app data.
    2. When you open analytics view for some tracking property, make sure you have selected the right View (one you created for mobile app data). So, do not use "All Web Site Data" view.
    3. When doing this test today, I found out that if I first opened wrong web view and opened Realtime>Overview, and only then switched to my MobileAppData view, GA doesn't properly refresh the active page "type". You can tell the difference from the right side below Pageviews per minute/per second:
      • If it says "Top Active Pages", then it means it's the web specific view.
      • If it says "Top Active Screens", then it is the mobile app specific view.
      • You can manually re-select Realtime>Overview from left side to make sure you switch over to the correct view.
    4. WebGL platform is bit of a 'special case' in GUA in the way that hits are not sent from Editor when the selected platform is WebGL, as with a web platform the hits are technically passed to the browser engine to be sent. To see hits coming from the editor, you would actually need to switch the active platform to be Desktop. This limitation has always been there with this asset, but it is not very clear that this limitation exists, so I should somehow improve this in a future release.
    Hope this helps you!
     
    Last edited: Oct 19, 2021
  5. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    Hi,
    we are using the latest version of the plugin in a Windows IL2CPP project.
    We've received reports from Players that the offline cache can grow significantly in size and start lagging the application.
    After we just disabled the offline functionality in the analytics we don't receive any analytics from anyone anymore.
    We are using the latest version of Unity 2020.3 LTS and the plugin.

    Is this a known issue already?

    I did not have time yet to debug the plugin yet, I may do so at a later point and report back.
     
  6. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @Flow-Fire-Games
    Haven't received reports about this before, so it is a new issue to me.
    Do you know what kind of hit counts are we talking about, i.e. how significantly the cache file has grown? Megabytes, gigabytes...?

    If some user is always offline so that there's never chance to cleanup the cache while being online, I guess something like this can happen, and I have to admit this case is not fully covered in the code. The assumption has been that it is somewhat of an exception that user is offline, and that eventually user would be online.
    For such users, it may be necessary add a feature which deletes the cache or turns it off, if it seems to keep growing.

    I'm a bit surprised if just disabling offline functionality stops all analytics though. That should work as long as users are online while playing... So any debug info on that would be helpful. o_O

    You can send that stuff over email, contact \at\ strobotnik.com.
     
  7. swiftjojo

    swiftjojo

    Joined:
    Oct 15, 2019
    Posts:
    2
    Is this working with Google Tag Manager?
     
  8. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @swiftjojo, thanks for the question. I'm not familiar with the tag manager service, so I can't give very definitive answer.

    But, after looking shortly into this, I'm quite sure that you couldn't get it to work "out of the box" with this asset, although it would probably be possible with relatively small amount of changes.

    Doing any such manual changes would fall out of support though, and at least for now, I'm not planning to add support for integrating tag manager.
     
  9. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305
    For most it doesn't seem to be noticeable, a few megabytes at best.
    We just started to work with the plugin so we barely report any events yet.
    From one user I've seen a screenshot of 200mb size.
    He is on the very low end of the system requirements in RAM and I assume that the exception reporting is collecting all kinds of errors and does not free it.
    This user was the first who made us aware of the issue by sending us this screenshot.
    unknown.png

    He was chatting with us from the machine in question while the game client was doing the performance problems, deleting the cache and later us disabling offline caching fixed it for him.
     
  10. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Thank you @Flow-Fire-Games for the extra info.
    In what kind of period did that user's 200MB of hits

    The GUA allocates as little memory as possible. The offline cached data is immediately put into hard disk, and when it's possible to send those later, they are read from there one at a time, so it's not keeping all of that in memory.
    I suspect there's some unfortunate combination, something like this: (1) user plays many sessions and often, usually offline, so analytics hits are cached, (2) application generates as much hits as it can, very likely way over the limits, and (3) user is sometimes online but only shortly - hit cache is only partially sent in the background, and then goes offline again, while new hits are still being generated (again to cache). When something like this happen, I guess the moment when network works, there is some slowdown when switching from cache writing to cache reading, and reading through the cache file to skip to the first pending hit.

    For now, I'd advise you to do these steps:
    1. Verify that you're not generating too much hits, perhaps your analytics usage needs some re-designing.
      • I think generating too much hits (over the limits) is the true issue in this case.
      • Why? Let's consider 200 MB hit cache. If we'd assume one hit is roughly 100 bytes (more or less). That would mean there are over 2 million hits in the cache. That would represent 20% of all monthly possible hits for the whole app (all users combined), so it is quite surely way too much.
      • Please read carefully the hit limits from here: https://developers.google.com/analytics/devguides/collection/protocol/v1/limits-quotas
        Just to make the point, here's the current info:
      • Maximum of 500 hits per session (start game, play, close game). So those 2 million hits would at least 4000 sessions.
      • Maximum of 200000 hits per user per day. So 2 million hits would mean at least 10 days of play time with this very drastic maximum.
      • Notice that hitting these max limits would mean you would be able to have only few users in total to stay under the limits.
      • GA 360 paid accounts allow for larger limits, but this "2 million hits" is so much that it wouldn't make a difference, it'd still be too much.
      • Just for one more comparison: let's consider user would play offline 30 days, 10 sessions every day (quite a lot?), and that you'd generate 100 hits per session (nicely under the maximum), and average hit length would again be 100 bytes. This would mean that after one month offline cache file would still be about 3 megabytes, far from that 200 MB.
    2. Make sure you have opt-in (and opt-out) UI for Analytics in the game options.
      • If/when user opts-out from analytics, the offline queue file is deleted (you can verify this in analyticsDisabled property set {...} implementation). But perhaps this is how you already instructed to disable&delete the cache.
    If you find the need to debug this more, make sure you enable GUA_DEBUG_WARNINGS and GUA_DEBUG_LOGS in GoogleUniversalAnalytics.cs, maybe not just in editor but also for builds, and check if there are any surprise warnings.

    One more question - are you targeting the UWP platform or plain desktop windows?

    Once I have the time to look into this, it of course looks like I should build some kind of failsafe for this kind of case.
    Perhaps it would be more warnings for developer (about going over assumed quotas). Or something more drastic like automatically clearing the cache (or refine the cache logic) when it grows unexpectedly big. After all, GA doesn't process "too old" hits anyway.
     
  11. Flow-Fire-Games

    Flow-Fire-Games

    Joined:
    Jun 11, 2015
    Posts:
    305

    I'm not worried about the content of the offline cache for the moment, in his case it's probably weird exception spam that is already fixed or at least unique to his case.
    But we don't receive any data from any client anywhere after opting out of "Use Offline Cache" in the script, nothing else in relation to analytics has changed.

    Capture.PNG

    We still receive hits from older Client versions.
    Game is compiled plain Windows IL2CPP x64.
     
  12. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Thanks @Flow-Fire-Games, that additional info was helpful.
    When thinking about this, somehow I missed the fact that sending exceptions could generate lots of analytics hits spam. I should definitely add some "max limit" for that to a future version. That is actually probably the most effective way to fix the reported "slowness issue", as any normally reasonable usage (within limits) shouldn't generate so much data that it would cause slowdown. I will also try to see why disabling Offline Cache would stop hits from arriving.

    However, I'm quite busy right now, so it probably will take some time until I can put aside time for this. For now, I recommend you would disable "Send Exceptions" flag, until a new version of the asset is available.
     
  13. Michele_P_LF

    Michele_P_LF

    Joined:
    Oct 18, 2021
    Posts:
    9
    Hello @tonic!

    I am investigating the possibility of tracking GA custom events in Unity and came across your asset. Could you confirm that it is possible to track unity custom events using the Measurement protocol with your asset? Do you support Universal Analytics only or GAV4 as well?

    Either way, I believe to register a property on the analytics dashboard and obtain an UA-XXXX ID to send events to it, it is necessary to associate the property with a website domain. Could you confirm whether this is necessary with your asset or not?

    Many thanks!

    Michele
     
  14. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @Michele_P_LF

    1. Only "Universal Analytics" is supported. I've kept an eye on GAv4 but not decided if I will write code for it.

    2. Yes, you need to provide some Website URL when setting up the property. However, you will then also create a "Mobile app" view, and the submitted hits will show up in that view, so GA does keep a distinction.
     
  15. Michele_P_LF

    Michele_P_LF

    Joined:
    Oct 18, 2021
    Posts:
    9
    Hi @tonic

    Sounds good, thanks for letting me know!
     
  16. Blarp

    Blarp

    Joined:
    May 13, 2014
    Posts:
    269
    def consider ga4 because universal is being shut down.

    Also with USD file format, this will be very important to measure things in the web "mod viewer" when web 3d starts to get more big later this year (because of USD format and scene exporters)
     
  17. Blarp

    Blarp

    Joined:
    May 13, 2014
    Posts:
    269
    GA4 plrs! Will send Jersey Mikes gift cards. Crack that whip with oil and vinegar
     
  18. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @Blarp!

    I am sorry to say but I am too busy with other things that have a higher priority. So it looks like in the very near future I won't have time to spend on GA v4 support.

    So, my current thinking is that this asset will be deprecated some time next year. It is a distinct possibility that I will consider making a new asset with upgrade path from this one, but I cannot make any kind of promises.
     
    Blarp likes this.
  19. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Here is a warning for anybody who ends up reading this thread. (I have also modified the 1st post, as well as the asset home page.)

    Google has announced that support for Universal Analytics will end on July 1, 2023.
    They recommend using Google Analytics 4 instead.

    This asset does not have support for Google Analytics 4.

    If you purchase this asset, please understand that this particular asset will stop working on July 1, 2023. Because of this, the price has been reduced.

    Sales of this asset will be likely discontinued at the turn of the year 2022-2023 or soon after.
    After that, it will be changed to "deprecated" status, and will be available in Unity Asset Store only to those who have purchased it earlier.

    We're still considering the possibility of creating a different asset (with an upgrade path from this asset).
     
    Last edited: Nov 3, 2022
  20. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Big thank you to all of you who have used this asset, and thank you for the feedback!

    "GUA" has been the solution for roughly 10 years to combine Unity and Google's "Universal Analytics".
    It was the first such asset, and has outlived the few other solutions that have offered roughly the same thing technically. This includes even the "official" repository of adding universal analytics to Unity with measurement protocol.

    PS. To my knowledge, the official GA v4 SDK still only supports very limited amount of platforms (iOS+Android).
     
  21. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Some of you have even emailed and asked for a new version. There is a new GAv4 API which would seem to be the natural choice to upgrade to. However, there is a statement on the API page that the intention is only to augment Firebase, not to replace it. So new version of this asset is likely off the table, unless that statement is changed or further clarified.

    If someone still weirdly has a reason to buy the asset, now's your last chance (still available for a reduced price). But, be warned, it will remain functional only for a few months.

    Thank you again! The asset will be deprecated soon.