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
    Yes all the measurement protocol parameters are reflected in the API. If you want to peek at the doxygen docs of the current version (1.3.0), download this zip file. That's a little bit outdated - there are some changes and addition to the parameters, and the next version will be up-to-date (1.4.0 coming soon).

    In the API most of the parameters are implemented in form of "add"-method, meaning that you can add the data in when building a custom hit, e.g. with this kind of list of calls: beginHit(hitType) + addCampaignName("testcampaign") + addCampaignSource("internalcrosspromo") + sendHit(). Next version 1.4.0 will also have a few small changes, with a few of those add-type of methods changed to "set", meaning that you set them once and then they are automatically added to all hits afterwards - for the ones where that seems to be a good idea: e.g. setIPOverride, and also addApplicationVersion will be replaced with setApplicationVersion.

    Those are included as part of the API as well. But there is no automatic integration of any advertisement/campaign/distribution systems, so it is up to you to read that kind of info and submit the info to GA using this API.
     
  2. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
  3. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    This package doesn't have any integrated crash interception, which should be done platform-specific way for each platform for proper functionality.

    That being said, if you integrate some other package which logs crashes, and you can read back that info on next application startup, then it should be easy to send that info to the analytics using HitType.Exception (see sendExceptionHit helper method).

    If you are running on iOS and you have Unity Pro license, then one way to implement that is using Unity's own CrashReport API.
     
  4. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Why not have your package implement something along the lines of http://entitycrisis.blogspot.jp/2011/01/error-reporting-from-your-unity3d-game.html

    That would be extremely useful
     
  5. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
  6. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    I went ahead and bought it and I'm trying to test this function but can't seem to get GA to recognize the exception hits.

    eg:

    void Awake()
    {
    Application.RegisterLogCallback(HandleException);
    }

    private void HandleException(string condition, string stackTrace, LogType type)
    {
    if (type == LogType.Assert ||
    type == LogType.Log ||
    type == LogType.Warning ||
    type == LogType.Error ||
    type == LogType.Exception)
    {
    m_ExceptionCount++;
    string error = String.Format("{0}: {1}\n{2}", type, condition, stackTrace);
    Analytics.gua.beginHit(GoogleUniversalAnalytics.HitType.Exception);
    Analytics.gua.addContentDescription("HandleException");
    Analytics.gua.addEventCategory("Exception");
    Analytics.gua.sendExceptionHit(error, true);
    }
    }

    Any clues?
    Is there a limit on the message size?
    Or is it just because there is no real time view for exceptions?
    Do I have to wait for Google to process them and have them show up in Behavior/Crashes and Exceptions?
    (Is this where they are supposed to show up btw?)
     
    Last edited: May 15, 2014
  7. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @sonicviz:

    About your test source: If you build a custom hit like that, i.e. you use the beginHit(...), then you should end it with plain sendHit(). In addition to that you might want to use addExceptionDescription and addExceptionIsFatal.

    Please peek at the implementation of sendExceptionHit -- it is not a replacement for sendHit but instead a self-contained helper method for doing the begin...add...send -stuff for you. So instead of calling begin add -stuff yourself, you could only say: Analytics.gua.sendExceptionHit("crashed", true);

    There is a limit of 150 bytes for the exception description length defined in measurement protocol. Unfortunately I'm quite sure combination of type condition strack trace is going to be too long. You might want to try using a regular event hit type to record that (with e.g. event category "exception" and the type+condition as event action, and then event label containing stack trace). Max length of event label is 500 bytes.

    If you manage to test the stuff when running inside editor, the debug warnings should be automatically enabled, and there will be a Debug.LogWarning if you go over the length limits. (see start of GoogleUniversalAnalytics.cs and tweak the #define stuff if you want to enable logging of those for other builds than running inside editor)

    And yes, when you're not seeing the data immediately, then you generally have to wait 24 hours or so until the data is processed.
     
  8. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    ah, right...I actually did this in the beginning and didn't see anything so read the docs and it seemed I needed to do BeginHit etc

    I'll see if anything pops up in GA over the next 24 hours.

    I have a suspicion this may not work anyway due to the small size limitations on content.
     
    Last edited: May 15, 2014
  9. Victor_Kallai

    Victor_Kallai

    Joined:
    Mar 5, 2014
    Posts:
    123
    Hello,
    When you call initialize and you set your appName, you should also set your bundle Id. Is there another way to set your bundle Id?
     
  10. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Bundle id? ... Do you mean the tracking id? -- The tracking id must be available immediately at the initialization.
     
  11. Victor_Kallai

    Victor_Kallai

    Joined:
    Mar 5, 2014
    Posts:
    123
    Not the tracking Id. In google analytics I have a field for Application Name and a field for Application ID, which will be my app bundle id.
     
  12. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    By a quick look around I don't seem to find the place in GA site you're referring to, with the possibility of entering Application ID for the tracking Property.

    Any way, entering application ID has just recently been added to the measurement protocol specs, and it is optional (not required). The currently available version (1.3.0) of this asset doesn't yet have a way to set the id, but the next version (I will probably submit v1.4.0 update tomorrow or so) will have a method to set application ID as well, and it won't be necessary to set it at the initialization time.
     
  13. tydygunn

    tydygunn

    Joined:
    Aug 9, 2012
    Posts:
    13
    Hi Tonic. I bought this analytics package when it was on sale a few days ago and I'm VERY happy with it. Would definitely recommend.

    Any-who, can you suggest how I would send data to more than one google analytics application at a time? It's an application we made for a client, and we'd like to send the data to both their analytics account as well as ours. I thought I had it going (worked in the editor), but then it just crashes on iOS. Any ideas?

    Thanks for a great package.
     
  14. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi tydygunn, nice to hear you like it.

    How did you modify the package to suit your needs? It's a bit hard to imagine what could cause a crash on iOS... probably some relatively simple mistake. Perhaps you could try testing with some separate mini-app first, and test also with a stand-alone desktop build (which might make debugging easier).

    Sending to two different accounts isn't supported out of the box. But I think it should be only matter of a few little modifications. Here's at least the few things which probably need to be checked for:

    1) In Analytics.cs, change the "public static GoogleUniversalAnalytics gua" not to be static. After this you also have to modify any other code or example code which may refer to the gua object with Analytics.gua.something. Similarly you have to change setPlayerPref_disableAnalyticsByUserOptOut not to be static.

    2) In Analytics.cs Awake() method, where gua is initialized to be GoogleUniversalAnalytics.Instance, you need to replace with new GoogleUniversalAnalytics() instead.

    3) Barring some other things to fix (you'll find out when trying to compile), now you should be able to create two game objects with Analytics components having different tracking id.

    PS. I submitted v1.4.0 yesterday, which adds offline caching support for hits, as well as updates the API a bit to be in sync with the measurement protocol changes. If you can wait for a few days for the asset to be available, it might be better to do your modifications against that version, otherwise you have to do manually re-do them soon again.
     
  15. tydygunn

    tydygunn

    Joined:
    Aug 9, 2012
    Posts:
    13
    You were right, the crashing was something on my end that I've since fixed. Thanks for the suggested code edits. With a few adjustments everything is working just fine for me.
     
  16. Saioman

    Saioman

    Joined:
    Apr 16, 2013
    Posts:
    3
    Hi Tonic,

    Congratulations, your plugin is working fine out of the box.

    Now i need to post a Conversion-ID and a Conversion-Label to google analytics, how i can do this with your plugin?
    On official iOS SDK (i don't want to use them for multiple reasons) exists as "ACTConversionReporter" call, as you can see here: https://developers.google.com/app-conversion-tracking/

    Thanks.
     
  17. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi, nice to know it works for you.

    I was almost going to say that the conversion thing is out of scope for this package. But I looked a little bit further, and it seems you can link your Google AdWords and Analytics account. So perhaps it is possible to have the conversion tracking info go to the AdWords through the Analytics.

    I don't have personal experience from tracking advertisements and conversions from them, so unfortunately I can't give any real advice.

    I found this web page which might be helpful for you:
    https://support.google.com/adwords/answer/2375435?hl=en

    Additionally, I think the conversion ID can be supplied by building a custom hit and using the addGoogleAdWordsID("your id here") method. I'm not sure where the conversion label should go, if it can be even supplied using the measurement protocol API.

    If this tracking is very important to you, then I'd still suggest you consider again if you could use the official SDK for it instead, which you already linked. To me it seems that might still be more reliable way, as then it would not be an absolute requirement to have the adwords&analytics accounts properly linked.

    If you happen to solve this and find the exact steps needed to get that ad tracking working (in connection to analytics), I'm sure others would appreciate it too if you'd report back here with tips.
     
  18. Saioman

    Saioman

    Joined:
    Apr 16, 2013
    Posts:
    3
    Hi,

    Finally we implemented a native solution for Android and iOS (only for this call, of course). It's not possible to do it on "unity only" environment.

    Thanks for your help.
     
  19. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    v1.4.0 is now available, which adds offline caching of hits what many have been asking!

    When user is offline, analytics hits are put to an offline cache. Internet access status is automatically monitored and verified. When online, cached hits are sent in the background with throttling.
     
  20. tydygunn

    tydygunn

    Joined:
    Aug 9, 2012
    Posts:
    13
    Hi again! Is there any way to tell the analytics that the user is logging off? I've got 20-ish web players that are sending info to the same analytics account and the user only spends 1-2 minutes playing each minigame. If at all possible, I would like to tell the analytics that the user is logging off so that way when they log on again it doesn't say 2 users, then go to another game it reads out as 3 users. So on and so forth.

    Thanks!
     
  21. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Excuse me but I'm not fully sure I understand what is your exact need.

    It sounds to me that perhaps you're not actually interested in how to log user off, but extending their session over different webplayer instances? If that is so, I unfortunately don't have a solution for you. But, to make that happen, I think it would work if you could communicate over the same client ID to each of those webplayers. See Analytics.cs Awake() method, and where the clientID is initialize by taking it from PlayerPrefs, or if not found, a new one is created ... you would need to get the existing clientID in some other way, e.g. by making hosting server to add it to html page and make some javascript which would communicate it to the unity app, or something. That kind of stuff is beyond scope of this package, so I can only some vague hints like this (if I even guessed correctly what you might be after).

    Anyway, to also answer just how to ""log off": That you can do by making an event which contains the session control parameter. E.g. like this:
    Analytics.gua.beginHit(GoogleUniversalAnalytics.HitType.Screenview); Analytics.gua.addScreenName("logoff"); Analytics.gua.addSessionControl(false); Analytics.gua.sendHit();
     
  22. EBailey

    EBailey

    Joined:
    Mar 3, 2013
    Posts:
    6
    On Windows Store and Windows Phone, the offline cache code generates an error since the StreamReader and StreamWriter and File are not available. Is there an easy way to go back to 1.3, or to get a fix?
     
  23. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Hi,
    I've implemented some tracking on a project and it seems to work fine.

    However, it doesn't look like the OS is getting set properly on desktop PC/OSX.
    I'm getting iOS showing up but desktop seems to be (not set)

    Did I miss something on the setup?
     
  24. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Sorry for slow reply (I guess the forum update made me miss thread update notifications or something).

    EBailey - Sorry for the mistake of not realizing that. For next release I'll try to fix that so that it at least compiles w/o the offline cache support, and hopefully also get around to implementing it differently for those platforms. I sent you PM about the v1.3.0.

    sonciviz - Hmm. Do you use the (mobile) app view in GA site? In my tests I can see clients recognized as "Macintosh" (Audience->Devices and Network->Devices, primary dimension Operating System), although I do have some "(not set)" ones as well. But now that I think of it, I need to check if e.g. mac web player clients report differently vs standalone builds (+how in-editor differs). I guess maybe I need to write some custom stuff for that like it's done for iOS. For another way to see OS stats, read the manual chapter "Example of Creating a Custom Report". And if you happen to really need a quick workaround for reporting OSX for hits, you can use Analytics.gua.setUserAgentOverride after initialization (with some applicable user agent copy-pasted from what some OSX browser uses).
     
  25. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Further clarification: the v1.4.0 does work as is on Windows Phone. I had the nagging feeling that I did test on it, but wanted to check before I just say so. (I just verified this. I did have a weird issue with the example scenes related to OnGUI but the analytics part of the code seems to run fine.)

    But, seems I totally forgot to do a test build on Windows Store, foolishly assuming it'd be more or less equivalent to WP in this case. But there is a clear difference what's available in System.IO between those two.

    Edit: It looks like there is a nice porting reference how to solve this (and other things), here: https://github.com/windowsgamessamp...atformerPlugin/MyPluginUnity/Legacy/System/IO
    Be sure to read the "Porting tips..." pdf links as well on the main page: https://github.com/windowsgamessamples/UnityPorting
    I'll look into testing that implementation and incorporating to the next version.
     
    Last edited: Jun 9, 2014
  26. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    v1.4.2 has been submitted for review.

    Changes:
    - Fixed offline cache for Windows Store builds.
    - Added use of custom User-Agent on OSX.
    - Changed method of generating anonymous client ID.
     
  27. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    v1.4.2 is now available!
     
  28. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    @tonic, just came across this after searching for a possible alternative to Flurry Analytics, and from various comments it looks good. Can you simply send events like you would with Flurry, i.e. a name plus a dictionary of parameters?
     
  29. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @andymads Yes it is simple to send a "custom event", although you can't give a dictionary of parameters. An event has category & action, and optionally a label and a value. In addition to events there are also specific hits, like app screen hit to inform what screen user moved to.

    (Sorry for slow reply; I'm having problems with the forum not sending email notifications even if I reset the setting for that)
     
  30. yevdokia

    yevdokia

    Joined:
    Oct 1, 2013
    Posts:
    2
    @tonic, I'm considering getting GUA for our project, and I have a question.

    We have a web application (javascript) that uses Google Analytics. It also loads a Unity web player application. When the user is done, the web player application returns to the web application. We want to put tracking into the web player application and have it use the same ClientID as the javascript in the web application, so we know it's the same user. How would we do that using your plugin?
     
  31. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @yevdokia. Sorry for taking a few days to reply (I was abroad on a vacation). I haven't done much stuff containing communication between web page and Unity web player, but I can give a guess how your thing could be implemented.

    First you should decide which part you are going to use/get the ClientID from and then make sure the other part then usest he same ID. Sounds like your web application is the authoritative one (will have the ClientID first) and you'll only use the same ID later with the Unity web player.

    Then, after the Unity app starts, you should send the ClientID over to the Unity app. For details about how to do this, please read more from the Unity manual:
    http://docs.unity3d.com/Manual/UnityWebPlayerandbrowsercommunication.html
    I guess you'd need a custom script to Unity side which uses Application.ExternalCall to make a call to the web app html/javascript, and then in there you'd use the UnityObject2 to access the Unity web player and make a call which could be something like:
    u.getUnity().SendMessage("AnalyticsClientID", "setAnalyticsClientID", supply_fill_client_id_string_here);
    The above code row assumes you'd have a custom script (MonoBehaviour component) in Unity (let's call it AnalyticsClientIDFromWeb.cs) which contains method (function) named setAnalyticsClientID taking the client ID as string parameter. And this AnalyticsClientIDFromWeb component should be attached to a game object named "AnalyticsClientID".

    Then, you should only initialize the analytics in the Unity side when you get a call to the setAnalyticsClientID method. For this you'd need to modify the accompanying Analytics.cs (MonoBehaviour component) a little bit, perhaps renaming the Awake method to void myInitialize(string clientID) or something, and remove the code which generates a random client ID. (And probably also remove code which uses the client ID from PlayerPrefs and saves it there.)

    Hope this helps you!
     
    yevdokia likes this.
  32. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    I noticed the Google Analytics site may be giving analytics notifications about having bad event tracking code and info "(not set) entry present in reports for property [profile name]". I think this happens because of the 1st-time-launch client statistics hits sent by this asset automatically, so this shouldn't be anything to worry about. I'll try to get this fixed for next update.
     
  33. 3Lighthouses

    3Lighthouses

    Joined:
    Sep 15, 2009
    Posts:
    10
    @tonic Hi, I've been working with the plugin for a few days now and it's working fine from the web player. I want to retrieve back the data collected by Google and display it within my own game -- say, after a player makes a choice within the unity player, to immediately display a message (in unity) like:

    "23% of all players in Sweden made the same choice as you!".

    Is this possible with your plugin, or can I do it via Unity's WWW class? Is it possible at all? Your plugin is the first tool I've ever used to engage with Google Analytics. Can you advise on the best way to approach it?

    The plugin is nice and simple, by the way -- I like it.
     
  34. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @3Lighthouses - great to hear you like the asset.

    That's a pretty nice idea to potentially use the analytics data for. However, that is out of scope of this asset, which implements the Measurement Protocol API for data collection.

    Google does offer various reporting APIs for different kinds of tasks though. You can find a list here: https://developers.google.com/analytics/devguides/reporting/

    I believe you might be able to do what you want by using the "Core Reporting API". However, I'm not really familiar with it, so I'm not sure about it. If you are going to try it, I'd advise you to make sure you don't embed any private analytics accont authentication information in your game... (that is, if it looks like you would have to do that, then it is probably better to run the analytics data accessing code on your own server and make the game fetch simplified data from that).
     
  35. yevdokia

    yevdokia

    Joined:
    Oct 1, 2013
    Posts:
    2
    Thanks, @tonic! I implemented this, and it works perfectly.
     
  36. Timberoth

    Timberoth

    Joined:
    Jun 9, 2014
    Posts:
    2
    Sorry if this is a repeat question, but I know you mentioned GUA is not intended for crash interceptions. However is it possible to use it to turn on the automated crash reporting as mentioned in this article?
    http://analytics.blogspot.com/2013/02/5-things-you-should-be-doing-with.html

    They mention adding this line.
    <!-- Enable automatic crash measurement (Android) -->
    <bool name=”ga_reportUncaughtExceptions”>true</bool>

    I'm not familiar with the Android Java code side of things so maybe this isn't applicable to your plugin. If it is, it would very useful to be able to turn on the automated crash measurements.
     
  37. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @Timberoth, that's a good point, but not actually applicable to this asset.

    The reason is that this asset is built in a cross-platform way using the Measurement Protocol specification, with no native libraries -- that is, the official Google Analytics iOS or Android libraries are not included or used at all with this analytics asset.

    That leads to the tradeoff of not having the few additional benefits like the one you mentioned. But the positive side of the tradeoff is that this asset's code has a wider platform coverage -- it isn't limited to just iOS or Android, but it also works on desktop Windows & Mac & Linux, Windows 8 & Windows Phone 8, Web player plugin and reportedly also with Blackberry.

    So, for the crash reporting part, my recommendation is that you integrate a separate platform-specific solution. You probably can find a way how to feed some data from separate thing to Google Analytics as well -- for example by sending hits with the Exception hit type on the next startup.
     
  38. MozzieByteGames

    MozzieByteGames

    Joined:
    Feb 16, 2012
    Posts:
    9
    Hi,

    First I have to say, love this asset a lot! Unbelievably easy to implement!

    Is there a way to track data that consists of several parts? ie. coins collected, time taken, time remaining, etc.
    How would I go about doing this? Is it done using multiple sendEventHit() statements or is there a better/simpler way?
     
  39. tonic

    tonic

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

    If the data you want to send does not strictly need to be "together", then just send multiple events. Just try to calculate that the amount of events you send stays reasonable. Google Analytics has a limit of 500 hits per user session, but that should be plenty if you take some time to think of what you truly need or want to find out with analytics when deciding what to send. (By the way, if you go over the limit when running in editor, this asset will log a warning for you about that.)

    I'm just working on a big update (v1.5.0) and it's almost finished.
     
  40. MozzieByteGames

    MozzieByteGames

    Joined:
    Feb 16, 2012
    Posts:
    9
    Hi @tonic,

    Thank you for responding so soon.

    By "together" I mean that I would like to know about that data (coins collected, time taken and time remaining) and keep it associated within one event as I think the data would be more useful that way. What I'm trying to achieve is to identify how easy or difficult a level is within a game. I've not used GA before (or any other analytical tool for that matter).

    Looking at the examples commented out in Analytics.cs I noticed the sendItemHit() method that takes a few arguments. I am looking for something like it where I can add value/pairs ("Coins"/100,"TimeTaken"/63,"TimeRemaining"/38).
     
  41. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @MozzieByte, I can't claim to be an expert with in-depth knowledge of what are the best practices for various analytics integration details, but I can do my best to give some hints or ideas:

    For most of the time a simple event with well chosen category + action + label + value should be enough. Those "go down" in hierarchy when you view the events in GA site, so that it is easy to see accumulated data of some specific thing.

    For your example data, you could try sending three events like this:
    Analytics.gua.sendEventHit("Level1", "Completed", "Coins", 100);
    Analytics.gua.sendEventHit("Level1", "Completed", "TimeTaken", 63);
    Analytics.gua.sendEventHit("Level1", "Completed", "TimeRemaining", 38);
    This way when in GA site you go the path Behavior->Events->Overview->Level1->Completed, you can see each of those Event Labels and also the average value for each one.

    Note that there is also separately a Timing hit type which might be more suitable, but those of course go to a separate report page in the site (which may or may not be what you want).

    However, there are some questions what you probably can't answer since the example above doesn't strictly have that data to be connected to each other... for example, being able to know how much time left was there for ones who had 100 coins, versus ones who had only 10 coins.

    I can think of two ways to use GA to retain that data: (1) move the most important info "up" which could in this case for example be several versions of the Completed action -- e.g. "Completed with 1-30 coins", "Completed with 31-60 coins" or so... (suggesting some manual granularization there not to have 100 different completed events but just a few). Or (2) set up and use custom dimensions / metrics (which you can only have a limited amount) - read more from here: https://support.google.com/analytics/answer/2709829. In either of these ways you may want to consider if the Timing hit category would actually be better for this specific case.

    It's probably best to make a test property to the GA site, do some test submissions and determine which seems to work the best for you. It does take a bit of planning and waiting as the normal report pages in GA site are batch processed instead of being available immediately.
     
  42. MozzieByteGames

    MozzieByteGames

    Joined:
    Feb 16, 2012
    Posts:
    9
    @tonic, thank you for the valuable insight.

    You are correct in that I would like to know the time taken to collect 50 coins versus the time taken to collect 80 coins (as an example). The idea of dimensions sounds interesting and from what I can after having a quick read, looks like what I need.

    Cheers!
     
  43. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hello everybody!

    I just released a big new update: version 1.5.0!

    Here is list of what's new:
    - 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.
    - SystemInfo event changes for Unity 5.0+: Removed 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.

    Full list of asset features can be read in first post of this thread, in the asset store description, or in the website for Google Universal Analytics for Unity.
     
  44. MozzieByteGames

    MozzieByteGames

    Joined:
    Feb 16, 2012
    Posts:
    9
    Hi @tonic,

    I've been experimenting with custom dimensions and metrics. However, I'm not having much luck. Here is the code that I've knocked out and added to GoogleUniversalAnalytics.cs
    Code (csharp):
    1.     public void sendLevelCompletedDetails(string ScreenName, int Difficulty, int CoinsCollected, int TimeTaken, int LevelCompleted)
    2.     {
    3.         if (analyticsDisabled)
    4.             return;
    5.  
    6.         beginHit(HitType.Event);
    7.         addScreenName(ScreenName);
    8.         addCustomMetric(1, LevelCompleted);
    9.         addCustomMetric(2, CoinsCollected);
    10.         addCustomMetric(3, TimeTaken);
    11.         addCustomMetric(4, Difficulty);
    12.         sendHit();
    13.     }
    I'm then calling the custom method from within my game. Looking at the real-time views in GA I can see the screen hits coming through but the event I'm trying to send when I complete a level is not. Also, the data is not showing up later when I try to report on it.

    Can you see anything wrong with my code and/or approach to adding the metrics I require?
     
  45. tonic

    tonic

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

    I'm guessing it's about the used HitType. You could switch to HitType.Screenview since you're adding the screen name. Or alternatively to use HitType.Event I think the event category and action should be added.
     
  46. MozzieByteGames

    MozzieByteGames

    Joined:
    Feb 16, 2012
    Posts:
    9
    HI @tonic,

    You're right! I did indeed need to add the event category and action. I am trying to replicate the example provided by GA (https://developers.google.com/analytics/devguides/platform/customdimsmets#scope) under the section of Custom Metrics. In the example it appears to be an Event with the screen name added along with the custom metrics but, there's no reference to the two required fields.

    The reason why I do not want to re-use the HitType.Screenview again is to prevent doubling up on the count for the number of times the screen is viewed. My intention is to send an event along with the metrics I need only when the level has been successfully completed. This will make my reporting/analytics more meaningful.

    For those that are following along my code now looks like this:
    Code (csharp):
    1.     public void sendLevelCompletedDetails(string ScreenName, int Difficulty, int CoinsCollected, int TimeTaken, int LevelCompleted)
    2.     {
    3.         if (analyticsDisabled)
    4.             return;
    5.  
    6.         beginHit(HitType.Event);
    7.         addEventCategory("Level");
    8.         addEventAction("Completed");
    9.         addScreenName(ScreenName);
    10.         addCustomMetric(1, LevelCompleted);
    11.         addCustomMetric(2, CoinsCollected);
    12.         addCustomMetric(3, TimeTaken);
    13.         addCustomMetric(4, Difficulty);
    14.         sendHit();
    15.     }
     
  47. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Thanks for the update, nice to hear it works for you!
     
  48. MozzieByteGames

    MozzieByteGames

    Joined:
    Feb 16, 2012
    Posts:
    9
    Hello @tonic,

    I apologise for all the questions so far but, I have another issue that I have so far not been able to sort out and need some input as to what else I can check.

    My issue is that I'm not getting any event notifications going to GUA when I deploy the game to my Nexus 7 (with or without the development build flag set). Everything appears to work fine when I run the game from the desktop.

    I have also updated to the latest version (1.5.0), I also am using the 'free' version of Unity for the moment.

    Any thoughts or suggestions (polite ones) would be great as I'm tearing out my hair.
     
  49. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @MozzieByte, by saying that events don't get through, do you mean that you can see all other stuff fine -- e.g. screen changes in the Real-Time Overview page in GA site?

    First thing you could check is to check the View type you're using to see your data in the GA site. Go to Admin, select your Property and then check from the View if you have "All Web Site Data" or "All Mobile App Data" (plus any self created views perhaps). These are sometimes a bit confusing as it is even possible to use both with the same property, but for the app-generated analytics you should use view which is configured to track "Mobile app". You can create a new such view from the admin page (View->Create new view), and GA site will ask which type that view is meant for.

    Then, also check the app name parameter you're using. Does it match what you've defined in the GA site? Looking at some problem reports from others in the GA issue tracker I can see this has caused same problem in the past what you're having now.

    Another thing to remember is of course that data for most of the GA site pages is processed in batches. Which means the data is generally available a day later or so. (I'm not aware of the exact schedules.) Additionally you could also make sure you haven't accidentally set a wrong date period in the GA site (check top right corner).

    Finally, are you perhaps using the setUserID method? There is a recently added issue in the GA issue tracker where at least transaction events are lost if userID is present. I'm quite sure they'll fix this one soon.

    If the events are still missing after checking those things (but other things work properly), then I'm out of guesses... and it would sound to me like a bug in the GA itself, which would hopefully be a temporary glitch but could be a good idea to report as a bug after other possible mistakes have been ruled out. If you still have the problem after checking all of those, I could try to replicate the issue on my own, but for that it might be a good idea to have exact details of settings you're using so I could use the same, except with own tracking id (you could send those privately to me).
     
  50. MozzieByteGames

    MozzieByteGames

    Joined:
    Feb 16, 2012
    Posts:
    9
    Hi @tonic,

    Thank you for all the suggestions.

    Sorry for not being clear. By 'events' I actually mean all notifications including the screenHit notification that is sent from the OnLevelWasLoaded() method. Everything works fine as intended while running in the editor.

    I'm using the Real-Time Overview of GA to see the notifications coming through while running in the editor. But nothing comes through in the Real-Time Overview once the game has been deployed to the Nexus 7. Also, after checking the data in the Behaviour -> Overview and ensuring that dates are correct there is nothing there for the Nexus appearing.

    I'll try creating a small project and deploy it to the Nexus to ensure that it's not something that I'm doing.