Search Unity

Google Universal Analytics for Unity - Support Thread

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

  1. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    Now that our game is released on Android (Agent A), it's seems to be doing well so far in regard to the write access without needing permissions. Will update if I find out otherwise.
     
  2. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @jason_yak great to hear that, thanks for reporting back!
     
  3. michaelheiml

    michaelheiml

    Joined:
    Sep 21, 2015
    Posts:
    3
    @tonic

    Please help me with this: In our app, I use userID. I want to use user-based custom metrics (e.g. if the user is a premium user to distinguish all events from premium and free users). In the documentation is the method "addCustomMetric (int index, long value)" listed which creates a custom metric, but I can't figure out how to send an event with a custom metric. I already added the custom metric with index 1 to Google Universal Analytics via the web interface.

    According to this website, I would have to add the custom metric to the event that is sent, the code example is:
    googleAnalytics.LogEvent(newEventHitBuilder()
    .SetEventCategory("Achievement")
    .SetEventAction("Unlocked")
    .SetEventLabel("Slay 10 dragons")
    .SetEventValue(5)
    .SetCustomMetric(3,"200"));

    How do I achieve this using your plugin?
     
  4. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @michaelheiml, please have a look e.g. in the "void sendSystemInfoEvent(.......)" method in Analytics.cs for some reference. That shows how to make your own customized event hits.

    Between the calls beginHit ... sendHit, you should add the call for addCustomMetric.The logic in GUA API is that you build an analytics hit by first calling beginHit, then "add" some hit specific things there (like the custom metric), and then finally call sendHit.

    Please read the doxygen docs and/or source code to find out what pieces are required to be "added" by hit type. For example, for event hits, you must at least call addEventCategory and addEventAction.
     
  5. michaelheiml

    michaelheiml

    Joined:
    Sep 21, 2015
    Posts:
    3

    @tonic
    Thanks for your quick reply! I already wrote a new method following the ones that are already implemented, but I am stuck somewhere else:

    Code (CSharp):
    1.  
    2. public void sendEventHitWithMetric(string eventCategory, string eventAction, string eventLabel = null, int eventValue = -1, string eventCustomMetric = null)
    3.     {
    4.         if (analyticsDisabled)
    5.             return;
    6.  
    7.         beginHit(HitType.Event);
    8.         addEventCategory(eventCategory);
    9.         addEventAction(eventAction);
    10.         if (eventLabel != null)
    11.             addEventLabel(eventLabel);
    12.         if (eventValue >= 0)
    13.             addEventValue(eventValue);
    14.         if (eventCustomMetric != null)
    15.             addEventCustomMetric(eventCustomMetric);
    16.         sendHit();
    17.     }
    Code (CSharp):
    1.  
    2. publicvoidaddEventCustomMetric(stringmetric)
    3. {
    4. if(hitType !=HitType.EventWithMetric)
    5. return;
    6. stringdata=escapeString(metric);
    7. sb.Append("&ecm=");
    8. sb.Append(data);
    9. }
    10.  
    As parameter "eventCustomMetric", I pass:
    "{'metric2':true}"
    as string, but that might be the problem.

    The GUA doc gives this parameter as an example, but I can't figure out how to convert that to work with the plugin?
    .SetCustomMetric(3,"200"));
    Where the first parameter is the metric index (int) and the second one is the value (long).
     
  6. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @michaelheiml, I'm afraid you're a bit on the wrong tracks (there is no hit type of "event with metric", and there's no "ecm" in the measurement protocol).

    Perhaps try something like this:
    Code (CSharp):
    1. public void sendCustomMetricEvent(int cmIndex, long cmValue, string eventCategory, string eventAction, string eventLabel = null, int eventValue = -1)
    2. {
    3.     GoogleUniversalAnalytics gua = GoogleUniversalAnalytics.Instance;
    4.     gua.beginHit(GoogleUniversalAnalytics.HitType.Event);
    5.     gua.addEventCategory(eventCategory);
    6.     gua.addEventAction(eventAction);
    7.     if (eventLabel != null)
    8.         gua.addEventLabel(eventLabel);
    9.     if (eventValue >= 0)
    10.         gua.addEventValue(eventValue);
    11.     gua.addCustomMetric(cmIndex, cmValue);
    12.     gua.sendHit();
    13. }
    14.  
    And call it for example like this:
    // custom metric 3 and custom metric value "200", assuming no event label or value is needed:
    sendCustomMetricEvent(3, "200", "CustomEvent", "EventAction");

    Edit: also there's nothing taking in JSON in the API, so there's no point trying to pass strings like "{'metric2':true}".
     
  7. michaelheiml

    michaelheiml

    Joined:
    Sep 21, 2015
    Posts:
    3
    @tonic Thanks for your help, it works!
     
  8. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    The way to set up a new tracking property has changed, since currently the GA site will by default forward to using Firebase instead.

    The lower half of the following web page has instructions how to now set up tracking properties differently.
    https://support.google.com/analytics/answer/2587086
    That list applies to this asset as well. Here is copy of those instructions:
    1. Sign in to your Google Analytics account.
    2. Click Admin.
    3. In the PROPERTY column, select Create new property from the dropdown menu.
    4. Select Website.
    5. Provide a Website Name. You may use the name of your app.
    6. Provide a Website URL. You may use your company URL or the URL for your app’s marketing site.
    7. Click Get Tracking ID.
    8. In the VIEW column, select Create new view from the dropdown menu.
    9. Select Mobile app.
    10. Provide a Reporting View Name.
    11. Click Create View.
    Additionally, be sure to leave your newly created mobile app view "active" by selecting it in the views column. It seems that only when the view is selected, the real-time reports screen will show the Overview and Screens pages for app tracking, just as it used to be.
     
  9. ITSTH

    ITSTH

    Joined:
    Jun 11, 2015
    Posts:
    17
    @tonic: Can I use your asset to visualize funnels? Basically I need a nice graph showing which level(s) the user solved. Some levels may be optional. (UA can't do that, I think.)
     
  10. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @ITSTH, this asset is a wrapper for sending analytics hits to GA, so there is no any kind of own visualization features. All you get is what GA offers.

    GA website has support for funnels but it's up to you to figure how to best map analytics data from your app to there (beyond what I can help you with).
     
  11. radimoto

    radimoto

    Joined:
    Aug 23, 2012
    Posts:
    257
    Hi @tonic

    Just to let you know Google Universal Analytics fails on Unity 2017.1.0.f2 when building to IOS.
    Xcode logs an exception due to invalid characters.

    InvalidOperationException: Header value contains invalid characters
    at UnityEngine.WWW..ctor (System.String url, System.Byte[] postData, System.Collections.Generic.Dictionary`2[TKey,TValue] headers) [0x00000] in <00000000000000000000000000000000>:0
    at Strobotnik.GUA.GoogleUniversalAnalytics.beginWWWRequest (System.String postDataString) [0x00000] in <00000000000000000000000000000000>:0
    at Strobotnik.GUA.GoogleUniversalAnalytics+<netActivity>c__Iterator0.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0
    at Strobotnik.GUA.GoogleUniversalAnalytics.initialize (UnityEngine.MonoBehaviour analyticsHelperBehaviour, System.String trackingID, System.String anonymousClientID, System.String appName, System.String appVersion, System.Boolean useHTTPS, System.String offlineCacheFilePath) [0x00000] in <00000000000000000000000000000000>:0
    at Strobotnik.GUA.Analytics.Awake () [0x00000] in <00000000000000000000000000000000>:0
    Strobotnik.GUA.GoogleUniversalAnalytics:initialize(MonoBehaviour, String, String, String, String, Boolean, String)
    Strobotnik.GUA.Analytics:Awake()

    (Filename: currently not available on il2cpp Line: -1)

    This is due to the parentheses in the user-agent:

    customHeaders.Add("User-Agent", "Mozilla/5.0 (iPhone; CPU iOS 11_0 like Mac OS X)");

    if (customHeaders != null)
    return new WWW(useHTTPS ? httpsCollectUrl : httpCollectUrl, postData, customHeaders);

    If the parentheses are removed, there is no exception:

    customHeaders.Add("User-Agent", "Mozilla/5.0 iPhone; CPU iOS 11_0 like Mac OS X");

    I am in the process of uploading a bug report.
     
    Last edited: Jul 8, 2017
  12. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @radimoto, thank you for notifying about this! That certainly seems like an error in Unity, let's hope that'll be resolved quickly. :rolleyes:
     
  13. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @radimoto, additional note: if you want a quick workaround, it's a possibility to tweak the source a bit by commenting out the addition of custom-built user agent to customHeaders. And instead use the setUserAgentOverride(...) which supplies an user-agent override through the analytics API. In that case the hits will be submitted as whatever user-agent supplied by Unity, and GA should pick that overridden useragent for the analytics data.
     
  14. marbotic

    marbotic

    Joined:
    Apr 29, 2014
    Posts:
    3
    Hi everyone :)
    Hi @tonic

    I would like to understand how to use the custom dimension with your plugin.
    1) I clearly understand set up on Google Analytics.
    2) I tried to set all my event to my custom dimension "TypeProfile" by using "the code 1" screenshot. -> it didn't worked.
    3) i modified your code (see screenshot code 2) -> it worked.

    So either i didn't understand how you want us to use custom dimension or either there is a bug ?

    Thanks in advance for your advice.
     

    Attached Files:

  15. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @marbotic, you're definitely on the right tracks!

    For "exotic" use cases one is expected to make own helper method which builds an event with custom stuff and sends it. And the custom dimension stuff is such an "exotic" case.

    The first screenshot is definitely wrong, since the "addCustomDimension" is definitely meant to be used between calls to beginHit and sendHit. And that's what you have done in the second screenshot, so it works!

    The only thing I recommend is that you don't modify the included normal "sendEventHit" method, but instead move that customized version to somewhere in your own code and rename it. Just add using Strobotnik.GUA; and the Analytics.gua. prefixing to methods where needed. That way you can still use the regular sendEventHit in some other places, and a potential asset update later won't overwrite customizations.
     
  16. marbotic

    marbotic

    Joined:
    Apr 29, 2014
    Posts:
    3
    Thank you for your quick answer @tonic :)
     
  17. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
  18. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
  19. P4blo

    P4blo

    Joined:
    Dec 12, 2012
    Posts:
    18
  20. tonic

    tonic

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

    Sure it is. After initialization, you can do a single call to: void setAnonymizeIP(true). After that it's applied to all subsequent sent hits.
     
    P4blo likes this.
  21. P4blo

    P4blo

    Joined:
    Dec 12, 2012
    Posts:
    18
    Thanks for the quick answer @tonic , I have another question. About the license, do I need a license per seat or per project?
     
  22. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    No per seat license needed, as it's not an editor extension.
     
  23. naligator

    naligator

    Joined:
    Jul 24, 2014
    Posts:
    6
    Hi @tonic Jetro-

    It seems - Google allowing only firebase Google-Analytics Property for Apps.

    What do you suggest I should do ?
    Should I select APp and let google analytics set it to firebase ? OR should I select Website ?

    OR is it game over for Strobotnik Google Univesal Analytics ?

    Do let me know- am about to ship an app hence will appreciate a fast reply.


    https://drive.google.com/open?id=0B3b_uo7JziDdTXJybG5zSUMyOVk

    Regards,
    -N
    ps: have also emailed you about this!
     
  24. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @naligator, an earlier thread posting has the answer for this - repeated below.

    --

    The way to set up a new tracking property has changed, since currently the GA site will by default forward to using Firebase instead.

    The lower half of the following web page has instructions how to now set up tracking properties differently.
    https://support.google.com/analytics/answer/2587086
    That list applies to this asset as well. Here is copy of those instructions:
    1. Sign in to your Google Analytics account.
    2. Click Admin.
    3. In the PROPERTY column, select Create new property from the dropdown menu.
    4. Select Website.
    5. Provide a Website Name. You may use the name of your app.
    6. Provide a Website URL. You may use your company URL or the URL for your app’s marketing site.
    7. Click Get Tracking ID.
    8. In the VIEW column, select Create new view from the dropdown menu.
    9. Select Mobile app.
    10. Provide a Reporting View Name.
    11. Click Create View.
    Additionally, be sure to leave your newly created mobile app view "active" by selecting it in the views column. It seems that only when the view is selected, the real-time reports screen will show the Overview and Screens pages for app tracking, just as it used to be.
     
  25. inZania

    inZania

    Joined:
    Mar 3, 2016
    Posts:
    28
    @tonic First, thanks for the effective plugin; it's been producing good data. However I've also had the same problem re: headers. I don't think asking developers to comment out the custom header is the right solution. Though this may be considered a bug in Unity, you can work around it with proper character encoding in the GoogleUniversalAnalytics class: https://issuetracker.unity3d.com/is...n-when-user-agent-header-contains-parenthesis

    Additionally, I would appreciate it if you would mark your methods as "virtual" on the Analytics class. There are a couple cases where I wanted to better customize the functionality for my use-case.
     
    Last edited: Sep 20, 2017
  26. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @inZania, thanks for the kind words and feedback.

    I somehow first expected that the bug would have been resolved more quickly. I think there's certain amount of risk in encoding the parentheses, since normally that's not needed. If the encoded form is passed to server as is, then it's up to server to correctly decode them. So, it would at the very least take some back-and-forth testing to verify if the GA backend accepts that or not. Have you perhaps been using a modified version with the encoding, and verified it works?

    Another way should be to just use the API-provided setUserAgentOverride -method like I suggested earlier, without the above mentioned "risk". You're right this shouldn't be a hassle for users of GUA. I noted this down and will do something about in the next update.
     
  27. inZania

    inZania

    Joined:
    Mar 3, 2016
    Posts:
    28
    Thanks @tonic ! I did verify that my fix works by observing my "Macintosh Intel 10.2" platform in Google Analytics. I also have another fix: I added the Screen to the EventHit method, because the events were not logging the screens in which they appeared. Here's a paste of my working version.

    Ideally, the class itself would track the current screen and report it automatically.
     
    Last edited: Sep 20, 2017
  28. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Okay thanks @inZania. I recommend you make an own custom hit sending instead of modifying the built-in sendEventHit (but the idea is fine, i.e. making a cusomized hit sending based on what you want or need).

    Please remove that gist link though; while it's not the whole asset, it still exposes a large part of it to the public. :eek:
     
  29. inZania

    inZania

    Joined:
    Mar 3, 2016
    Posts:
    28
    Whoops, sorry about the gist. For some reason I was thinking this asset was publicly viewable anyways.

    While I agree with you that a custom function is a good idea in principle, it's not really possible because the class is sealed. I wish the class were partial and/or use virtual methods so I could tailor it better without my changes being overwritten whenever you push an update.
     
  30. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @inZania, I will give changing to virtual some consideration. However, what I've been recommending is to just make customized hit sending methods in your own class, like MyCustomGUAHits.cs or whatever. That is, make a method similar to the example in this post (#206), and put in a new MonoBehaviour class for example, just remember to add "using Strobotnik.GUA;" at the top.
     
  31. inZania

    inZania

    Joined:
    Mar 3, 2016
    Posts:
    28
    Yep, I get that -- but because the entire "default functionality" must be copy/pasted into such a function, it means if you ever upgrade the base functionality it would be easy for us to not get that upgrade. This is why I generally prefer that SDKs provide high levels of customization -- so that I might augment their functionality while still relying upon core helper methods that ensure any framework upgrades "come for free."
     
  32. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @inZania, inheritance & overriding virtual methods wouldn't help in this case, since the whole default functionality would still need to be copied over to the classes deriving from the GUA (that is, beginHit...addstuff...send stuff).

    The structure for building hits and sending them has been part of the public API of GUA and I think it has actually remained intact for the whole lifetime of the asset, likewise what's inside some of the base helpers like sendEventHit. So it should not be a problem to build own customized hit methods like I recommended. If you put the custom code to a separate class which just uses the GUA instance, then version updates should be safe for the main class (and in the past, features such as offline caching, have been added with the benefits coming just like you mentioned).
     
  33. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @inZania, I sent you privately a patch with a fix for the header issue for testing out right away.

    I'll try to release the updated version soonish, containing also updated instructions for setting up a new tracking profile.
     
  34. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Version 1.7.1 update is now available.

    It contains these changes:
    • Updated instructions for setting up new profiles in Google Analytics.
    • Added workaround for custom header bug in Unity 2017.
     
  35. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    I'm considering purchasing this, but can you tell me what advantages I get over using the official SDK provided by Google?
     
  36. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    This asset was originally released when Google had only released native iOS&Android libraries with no support for other platforms (or a separate Unity SDK). So back then the advantage was quite huge, as this asset worked on "any platform". Naturally now that Google has released their own free implementation for Unity, it is harder to compete against that.

    But there are pros and cons for each other, of course. I'll list some differences here and let you decide how important they are for consideration.
    (for brevity I'll call my asset "GUA" and Google's plugin "GAPlugin").
    • Core parts of GAPlugin are only supplied as pre-built native libraries, with no source code available
    • GAPlugin is relatively big with its largeish native libraries included - and on top of those libs there is also the C# side integration code and their version of measurement protocol code, which they use as a fallback for some platforms
    • GUA is really small with no separate backends by platform and no native code libraries are needed -- all platforms share same implementation which uses the measurement protocol (same pure C# code for all platforms, all source code is included in the asset)
    • GUA has no integration for install referrer or demographics tracking, while the native libraries of GAPlugin include support for those (Notes: I think referrer tracking was Android specific, and for demographics tracking you have to be careful with Apple limitations about IDFA usage)
    • GUA implementation is carefully written so that there are as little as possible allocations (less garbage collection).
    • GUA also works on Web player plugin / WebGL platforms. I don't know current status of GAPlugin, but when I once tested it (perhaps a year or two ago), it didn't just not-support web platforms through Unity, but even froze the browser tab when trying to use it. (Nowadays GAPlugin might work better, I haven't just tested it in a long while. If you test that, please let me know how it turns out.)
    • I'm not 100% sure about this, but I think GAPlugin does not support offline caching hits (queueing) and throttling of hit sending. (Or perhaps the support is limited to only iOS&Android which have different native library backends.) GUA has support for both, except on Web platforms these are not applicable. As part of the offline cache, GUA also automatically monitors if the Google Analytics server can be connected and starts pumping cached hits there in the background when internet connection works again. Note that I'm selling a generalized version of network connectivity tracking as a separate asset.
    • GAPlugin is still in beta. There seem to be quite large number of outstanding issues:
      https://github.com/googleanalytics/google-analytics-plugin-for-unity/issues
     
  37. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    Thanks! The official SDK from Google doesn't seem to get much attention, and I've seen users reporting alot of issues for V4. I guess they want to focus on their Firebase SDK..

    I purchased your asset and it's working great so far, though the tests I did from my android device was logged as "Unrecognized Device" in Google Analytics. Any ideas what could cause that?
     
  38. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @am_, hmm, a bit hard to say. What Unity version & android device/version are you using and testing with?

    If you're using 2017.x, then I guess this might be another new regression with the changed implementation of the WWW class (used for sending hits). It used to include correct user-agent on android without any customization, so have to check if that assumption has now become invalid. If that's the case, then the code will need an update to build a customized user-agent header on Android as well (already done that way on some other platforms). (I'll investigate...)
     
  39. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    Thanks, I'm using Unity 5.6.1p1.
     
  40. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    My initial guess seems wrong - I checked that both the new 5.6.4p1 and 2017.2.0f3 do report the user agent in similar format when compared to older Unity versions. I wonder if there's something weird in the GA happening. Are you sure the unknown device/version comes from the Android device and not for example from just testing play mode in Unity Editor?
    (Is that from the realtime view or the other views which update every night or something..?)
     
  41. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    Yeah, these are from my Android device which I installed the APK I built onto.
    It's reporting OS as Windows NT - it does however report the correct screen resolution at 1280x800 for my device.

    My device is running Android 5.1 (Kernel 3.10.72)

    Btw. maybe it would be a good idea to prefix hits from the Unity editor in your asset? Then it would be easy to filter out those test data appearing when debugging.

    My data is from the Audience > Devices and Network > Overview page. Both from past dates and current date.
     
  42. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    If the OS is shown as Windows then it's quite surely a hit from the Unity Editor.

    Some kind of prefixing is a nice idea, but leaves some questions open if it should be applied to everything (not just event names but also screens, transactions, whatever). I guess it's also a matter of preference if such test hits "pollute" the namespace of hits or are just among the actual hits. I think some people even use a separate profile for dev tests (as the amount of those is limited in GA, many probably view that an unwanted solution as well). But, I wrote the idea down to my TODO list for consideration at some point, in case I'll come up with some neat way for that.
     
  43. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    Thanks for the reply @tonic but I'm 100% sure this is coming from my Android app. When testing in editor the screen resolution is also sent as "Not set".
    Have you tried building an apk and submitting a hit to see what it reports? I can also try it out with a new profile in a new project to see if there's any difference then.

    I'll also check if it works on iOS when I have time.

    If you'd add a option (ie: Add editor-prefix in Play mode) to the Analytics script (like the Send System Info options etc.), you could use that to decide if you should append it to the hit-prefix string when in editor mode? Or as you state, add another input field on the Analytics script where the user can type in a Dev-Tracking ID in addition to the live Tracking ID.
     
  44. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @am_, yes, sorry, I was wrong. I just did a new test and indeed I'm getting "desktop" from an android phone in the GA realtime view.

    Since I already checked that the user agent strings sent by Unity haven't changed, I guess Google has recently modified the way they recognize the user agent strings. The user-agent string contains clear identification that it's an Android (with the version), and also the phone model. But otherwise it is not very much the same like what's sent by the mobile browsers.

    I think this needs to be fixed by creating a customized user agent code, so you'll need to wait a little bit. If you want I can first post an intermediate version to you privately for testing.
     
  45. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    EDIT: you can ignore this message, the issue turned out to be different (instead of deleting, the message is still included below in small print)

    when trying to figure this out further, I'm experiencing a bit weird thing.

    For some reason, GA (the realtime view) seems to misclassify the session type to "desktop" based on the first hit. However, when the same session submits further hits, GA reclassifies the session correctly to tablet/mobile based on what it is.

    Would be helpful to know if you (or somebody else) is seeing this same issue.
     
    Last edited: Nov 7, 2017
  46. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @am_, okay, I found the bug, and it is quite an embarrassing one. :oops:

    When testing a Unity 2017 related workaround for the latest release (1.7.1), I had temporarily tweaked the user agent generationg code, making windows UA always being used. Well, it was meant to be temporary.

    Anyway, I had mistakenly committed this tweak in GoogleUniversalAnalytics.cs initialize-method:
    The row:
    # if !UNITY_STANDALONE_WIN
    should be:
    # if UNITY_STANDALONE_WIN
    Notice the difference - removal of a simple exclamation mark.

    Sorry for this! You can fix this immediately by doing that change yourself manually, but I'll naturally soon release a fix for my mishap.
     
  47. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Version 1.7.2 update is now available.

    It contains these changes:
    • Added support for separate tracking ID used only in development builds.
    • Fixed custom User-Agent related regression bug introduced in 1.7.1.
     
  48. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    Thanks for the fix, and the new dev tracking id feature!
     
  49. Ghopper21

    Ghopper21

    Joined:
    Aug 24, 2012
    Posts:
    170
    Hi @tonic -- I'm educating myself about GUA and Google Analytics in general.

    A few questions:
    1. GUA is a wrapper around the HTTP-based Google Analytics "measurement protocol" -- correct?
    2. Does it provide a wrapper for the full measurement protocol API?
    3. I see Google pushing users to use their Firebase SDK instead of the Analytics-specific SDKs -- but that has nothing to do with GUA, since you are using the completely separate measurement protocol, right?

    Thanks!
     
  50. tonic

    tonic

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

    1. Yes, that's entirely correct. This asset is a helper API to construct and submit analytics "hits". There are also some extra features, such as automatic offline queueing and submission when it's possible again (however, GA limits how long hits can stay in queue). This is all done with C# code that's compatible across many platforms supported by Unity (but probably not all of them, e.g. I have no idea if this would work at all on the console platforms).
    2. Yes. If there's some really recent additions, then those might not have yet made it into the asset though. But the protocol has got only minor additions for quite a while now. (Note: while full api is wrapped, it's out of scope for this asset to include examples or support for all different aspects how one might use GA.)
    3. Yes, Firebase is a different thing. There are no plans to implement anything Firebase-related to this asset.