Google Universal Analytics for Unity®

DISCONTINUED
THIS PAGE IS HERE FOR ARCHIVAL / DOCUMENTARY REASONS.


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.
Please understand that this asset will stop working on July 1, 2023.

Sales of this asset are discontinued. The asset is now "deprecated". It is only available for download in Unity Asset Store for those who have purchased it earlier.

Big thank you to all of you who have used this asset, and thank you for the feedback!
"GUA" was the solution for roughly 10 years to combine Unity and Google's "Universal Analytics". It was the first such asset, and outlived all similar assets that existed for a short while.


This package brings Google's Universal Analytics to Unity®, with widest platform and Unity® version coverage using the same asset. This is the only Google Analytics integration library with all of the features listed below.

  • Ready-made Analytics component for drag'n'drop integration.
  • Automatic sending of errors and exceptions to analytics.
  • Automatic client System Info statistics (sent on first launch).
  • Automatic events when new level/scene is loaded.
  • Automatic caching of analytics hits when user is offline and throttled sending of cached hits in the background.
  • Automatic reachability check which determines if client is offline or the analytics server is reachable.
    (Generalized version of this feature alone is also available as a separate product: Internet Reachability Verifier).
  • Use the same code to implement analytics for Desktop, Mobile and Web builds!
    • Browser: Unity WebGL
    • Browser: Unity Web Player plugin (legacy)
    • Desktop: Windows
    • Desktop: Mac OS X
    • Desktop: Linux
    • Desktop: Windows Store
    • Mobile: iOS
    • Mobile: Android
    • Mobile: Windows Phone
    • Mobile: BlackBerry 10
    • (Not tested on console platforms, but if UnityEngine.WWW or UnityEngine.Networking.UnityWebRequest class works, then this should as well.)
    • Note: No support for certain platform-specific features, such as
      demographics reporting or automatic tracking of traffic sources (iOS / Android specific).
  • Example scenes to show functionality and how to implement user opt-out possibility.
  • Comes with documentation:
    • guide to set up your tracking property to a Google Analytics account
    • integration instructions
    • helpful hints how to interpret analytics results and make a custom report.
    • Doxygen documentation for the code.
  • Complete API for the Measurement Protocol of Google Analytics.
  • Support for new set of Enhanced E-Commerce analytics (first integration library to add that!).
  • HTTP and HTTPS support.
  • Toggleable debug warnings, e.g. if you're going over session hit limit (enabled by default when running inside editor).
  • Designed with goal of having minimal amount of memory allocations.
  • Custom-built user agent strings on the platforms where that's required to improve detection by Google Analytics.
  • Full source code included. Implemented in Unity with C#.
  • No need for big platform-specific library files.
  • No need to tweak project files for each platform.
  • Superior memory usage characteristics compared to some other integrations.
  • Maintained for a wide variety of Unity versions

  • Thread in Unity Forum

Note: The analytics service itself is run by Google, and offered for free but with certain features available only for Premium accounts. This package offers customized, optimized and easy integration of sending data to Google Analytics.


VERSION HISTORY

// 2023-07-01 - ASSET DEPRECATED. Google stopped supporting Universal Analytics. ★★ Celebrating success of supporting apps with an analytics solution for over 10 years! ★★

// 2021-06-28, 1.8.6 - Made sure UnityWebRequests will be properly disposed to fix Unity 2021+ warnings. Removed deprecated code.
// 2020-11-06, 1.8.5 - Updated instructions for setting up a profile in Google Analytics.
// 2020-09-23, 1.8.4 - Added addDisableAdvertisingPersonalization, deprecated content experiments methods. Fixes for Unity 2020.2. This is the last version to support legacy Unity versions from 3.x to Unity 5.6.6. (Support for Unity 5.6.7 will likely continue.)
// 2020-07-30, 1.8.3 - Minor iOS-related fix.
// 2019-11-20, 1.8.2 - Added custom user agent construction for Android, after default UA change in recent Unity versions.
// 2019-11-16, 1.8.1 - Fixed minor warnings with Unity 2019+. Always use debug tracking when running in Unity Editor, if debug tracking id is given.
// 2019-02-11, 1.8.0 - Use HTTPS by default. Use UnityWebRequest for sending analytics hits on Unity 2018.3+.
// 2018-05-24, 1.7.3 - Update for recent changes to measurement protocol specs: reduced content group limits and check for Enhanced E-Commerce product custom dimension max length. Changed "anonymizeIP" to be enabled by default. Fixed index clamping bugs in Enhanced E-Commerce code.
// 2017-11-07, 1.7.2 - Added support for separate tracking ID used only in development builds. Fixed custom User-Agent related regression bug introduced in 1.7.1.
// 2017-07-22, 1.7.1 - Updated instructions for setting up new profiles in Google Analytics. Added workaround for custom header bug in Unity 2017.
// 2017-04-07, 1.7.0 - Improved detection of Windows version. Added Tizen-specific User-Agent construction (not recognized by GA yet). Adjusted network connectivity test timings a bit. Wrapped GUA classes to Strobotnik.GUA namespace (in Unity 5 or newer). Added new AutoSendHitOnSceneLoad option (disabled, single, additive or always). Renamed internal DEBUG preprocessor directives to GUA_DEBUG. Minor fix for Universal Windows Platform (UWP). Added new method to API: addContentGroup.
// 2016-01-29, 1.6.2 - Support fix for Unity 4.7. Use SceneManager on Unity 5.3+ (fixes warnings).
// 2015-05-21, 1.6.1 - Show visual warning when using example GA tracking property ID in own projects. Minor tweaks to WSA/WP compilation. Use newer/alternative automatic user language determination code on all platforms, mainly to fix iOS/IL2CPP 64-bit issues. Fixed asset store Unity 5 warning.
// 2015-05-08, 1.6.0 - Added support for Unity 5 WebGL platform. Clarified docs to reflect latest changes in measurement protocol specs. Added debug data validation warnings to send*Hit convenience methods. Added sendExceptionsAlsoFromEditor checkbox to make sending of exceptions optional when running in editor. Minor compile fix for Windows Store builds. Added new methods setDataSource and setGeographicalOverride.
// 2014-11-28, 1.5.1 - Small tweak to sendPageViewHit and its documentation. Upgrades for latest additions to measurement protocol: added addDOMInteractiveTime and addContentLoadTime. Verified Unity 4.6 compatibility, and made small changes to add preliminary compatibility with Unity 5 beta.
// 2014-08-29, 1.5.0 - Added option for automatically catching and sending of app errors and exceptions to analytics. Added Tooltips to component fields (for Unity 4.5 or newer). Changed SystemInfo events to be non-interactive and made sending of them an option, and when running on Unity 5 removed sending of deprecated graphicsPixelFillrate and added graphicsMultiThreaded. Moved user language setting to be part of the auto-added hit data and changed auto-initialized language to be in the language code format instead of plain English. Added custom user agent construction and usage for Windows desktop and Linux standalone builds. Added parameter category to start of the short doxygen doc info strings. Added big list of new "Enhanced E-Commerce" methods (if you want to use these, you should apparently replace existing E-Commerce code with new code using methods which belong to this category). Replaced addAnonymizeIP with setAnonymizeIP. Replaced addUserLanguage with setUserLanguage. Added cancelHit. Refined offline cached hit handling to cancel sending of hits with time way too far away from current time. Only for Web player builds: you can give null as the url string to addDocumentReferrer method, which means that the web page document.referrer will be used instead.
// 2014-06-16, 1.4.2 - Fixed offline cache for Windows Store builds. Added use of custom User-Agent on OSX. Changed method of generating anonymous client ID.
// 2014-05-12, 1.4.0 - Added offline caching of hits when not online, and internal way to track internet access status (is GA site reachable). Cache is automatically cleared when online, with throttled sending of hits. Updated API for latest changes in Measurement Protocol, and a few other API changes (see docs).
// 2014-02-18, 1.3.0 - LogError for trying to use default dummy Tracking ID or warning when using the example's ID. Use custom User-Agent on iOS (improve device detection). Fixed reset of sessionHitCountResetPending.
// 2013-12-17, 1.2.0 - Revised setup & integration instructions, with new example for making a custom report. Added new calls to set up link ID or content experiment parameters. Added built-in way to disable analytics for easier user opt-out & updated examples.
// 2013-12-12, 1.1.4 - Minor fix for trying to use Handheld class on Windows 8.
// 2013-09-25, 1.1.3 - Unity 3.5 support, minor tweaks.
// 2013-09-01, 1.1.1 - [First public release for Asset Store!] Session hit limit debug warning. Granularized some of the system info statistics. Different way to generate client ID for Android. Send 1st launch data only when network is reachable.
// 2013-06-28, 1.1.0 - Support for web player running in browser.
// 2013-05-03, 1.0.1 - Common instance, check for Internet reachability. Automatic events with OnLevelWasLoaded.
// 2013-04-26, 1.0.0 - Initial version.


Below:   Image of setting up Analytics component in Unity




Did you like how this Google Universal Analytics package was built?

Also from Strobotnik for Unity®:
Klattersynth TTS
Pixel-Perfect Dynamic Text
Internet Reachability Verifier

Strobotnik is a member of the Unity Affiliate Program.