Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[Released] Google Analytics SDK

Discussion in 'Assets and Asset Store' started by stanislav-osipov, Jun 9, 2014.

  1. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    You can easily implement all power of Google Analytics to your Unity game.



    Documentation | AssetStore Page

    Plugin has clean and easy to use implementation of Google Analytics Measurement Protocol. Straight forward use examples inside.


    As a developer, you can extend the functionality of the Google Analytics service — from customising data collection for web and mobile, to programmatically accessing Analytics view (profile) and reporting data, to building your own Analytics solution. The Google Analytics developer platform provides access to the resources used to collect, configure, and report on user interactions to your online content.

    Getting Started

    Plugin Features

    Scripting API

    Automatic Tracking
    • Scenes
    • Exceptions
    • System Info
    • App pause
    • App quit


    PlayMaker Actions List:
    • GA_EventHit
    • GA_ItemHit
    • GA_PageHit
    • GA_ScreenHit
    • GA_SocialHit
    • GA_TransactionHit
    • GA_UserTimingHit

    I would love to hear your feedback and feature requests.
    If you need technical support feel free to drop e-mail to stans.assets@gmail.com
    Cheers!
     
    Last edited: Dec 4, 2014
  2. TwisterK

    TwisterK

    Joined:
    Oct 26, 2010
    Posts:
    110
    Hi, I just bought the plugin, it is easy to setting up and work straight away within minutes.

    One question though, how would the plugin handle if the user is not online, will it cached the send request and re-send it?
     
  3. Stans-Assets

    Stans-Assets

    Joined:
    Jun 20, 2014
    Posts:
    57
  4. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    The latest update is have just what you asked for.
    Now plugin will save api calls if no internet connection detected, and will try to send it again when the network available.
    Cheers!
     
  5. sebastiansgames

    sebastiansgames

    Joined:
    Mar 25, 2014
    Posts:
    114
    Hey looks great so far! Quick question-- I see in the Advanced Tracking Parameters that there's a checkbox 'Send From Editor.' Does that mean tracking data will be sent from running my app within Unity?
     
  6. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Yep.
    Basically there is few option here. Using this check box and multiple account system.
    You can:
    * Disable analytics tracking while you or your team working in editor
    * Enable analytics tracking while you or your team working in editor
    * Enable analytics tracking in editor, but all analytics data will go with another analytics ID.

    Cheers!
     
  7. TwisterK

    TwisterK

    Joined:
    Oct 26, 2010
    Posts:
    110
    Awesome! Thanks for the update!
     
  8. robertwahler

    robertwahler

    Joined:
    Mar 6, 2013
    Posts:
    43
    Thank you for publishing such a useful asset at a very reasonable price point. I just started testing it yesterday. Everything works great, it was very easy to integrate into our current project.

    I do have a couple of concerns after quickly reviewing the code.

    I like the caching but I'm concerned that there isn't a limit to the amount of off-line data collected by the prefs system. I wonder if there shouldn't be a limit that when exceeded, should start dumping old data? Also, there might need to be a throttle (if there isn't already), to prevent stalling the app when there is a large backlog of cached data.

    Regards,
    robert
     
  9. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Good point will do this.

    I am not sure what you mean. PlayerPrefs looks like a perfect solution for storing the data on a various platforms.

    Cheers!
     
  10. robertwahler

    robertwahler

    Joined:
    Mar 6, 2013
    Posts:
    43
    PlayerPrefs is fine, but what happens if a user is off-line for many days or never goes on-line. Does player prefs fill up with data?
     
  11. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Basically there are no hard limits for PlayerPrefs , with exception of WebPlayer, which is limited to a 1 MB. But WebPlayer is always online, so no worries about this :)
     
  12. robertwahler

    robertwahler

    Joined:
    Mar 6, 2013
    Posts:
    43
    PlayerPrefs getting very large is still an issue even if there are no hard limits.
     
  13. crossfd

    crossfd

    Joined:
    Jul 25, 2014
    Posts:
    1
    Hello, bought this plugin recently. One question. If I want to use this plugin for iOS, do I need to insert the Google Analytics SDK into the Unity generated XCode project?
     
  14. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,125
    have you released that version?

    at GA is it possible to send events with the past time stamp? will cached events look they occurred on when they sent or when they created?
     
  15. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Nope, everything is works out of the box.

    yep, it's available on asset store


    Good point I can actually add this as option
    https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#qt
    But this part is scares me:
     
  16. Lars-Kristian

    Lars-Kristian

    Joined:
    Jun 26, 2013
    Posts:
    64
    Thanks for creating this asset it is super useful. Got it up and running in no time.
    Android and standalone worked fine but I am not able to get it to work in the web player. Do you have any idea of what I am doing wrong? I am using the new beta of 4.6 if that is the problem?
     
  17. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    it should work on web player as well. So it looks like a bug. I will check this. But it should be also great of you could send me your project to check if you did something wrong with API usage or settings.

    Just use stans.assets@gmail.com

    Cheers!
     
  18. Lars-Kristian

    Lars-Kristian

    Joined:
    Jun 26, 2013
    Posts:
    64
    I have reseached the problem some more and this seems to be the problem. http://docs.unity3d.com/Manual/SecuritySandbox.html
    Has the web player work before?
    Would it be possible to send the GA-data to a javascript function on the webpage and then transfere it with ajax?
     
  19. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Thanks for report. I am on it :)
     
  20. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Done. Now web player analytics working as it should.
    The v1.9 should be live soon.

    Cheers!

    P.S. I will send you updated version by e-mail.
     
  21. bariscigal

    bariscigal

    Joined:
    Oct 26, 2009
    Posts:
    46
    How does the asset behave on ios platform? It seems most of the tracking services are using something apple doesn't want them to use. ADFramework without advertisement creates problem with Apple.
    Does this work out of the box without Apple store rejections?
     
  22. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Well, I do not see the reason why it can be rejected.
    I use custom header for web requests to tell analytics that we on IOS platform. So basically all analytics is just simple Unity WWW calls.
    Cheers!
     
  23. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,125
    i used one of former version of this asset on my game and it is online now for ios.

    Stan, is it possible to cache analytic data and send them like they occured on online time. i know google does not except more than 4 hours older records. there may be a tag for offline records and we can get reports with and without offline records.
     
  24. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hey atmuc.
    Can you please explain what you mean by:
    Cheers!
     
  25. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,125
    for example player has no internet connection for 5 days. you cannot send analytics data as occured on 5 days ago. google says you can send it maximum 4 hours early time stamp. when this player connect internet you should send analytics data as it occured on internet connection time. how do you send cached data?

    player plays offline at 01.01.2014
    player connects internet at 05.01.2014

    how do you send data occured at 01.01.2014?
     
  26. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    In this case those analytics data will be lost, so what do you suggest?
    I do not actually see the appropriate way we can modify time stamp for google to except it but it will not be correct data anymore.
     
  27. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,125
    i suggest to send them like they happened current time not the actual time. send them like they played at 05.01.2014. so i can collect offline data. it will be correct sum for how many players played my game for how many times. it will not correct for time line but i need correct sum.
     
  28. FlyingRobot

    FlyingRobot

    Joined:
    May 5, 2012
    Posts:
    456
  29. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Well I guess it will not fit for everyone, so I will add this as option which can be enabled / disabled.


    I haven't found this in documentation, so not sure. But I will search more about it, and let you know how it goes.
    https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters

    Cheers!
     
  30. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,125
    you are right.being optional will be the best. thanks.
     
  31. FlyingRobot

    FlyingRobot

    Joined:
    May 5, 2012
    Posts:
    456
  32. LukasO

    LukasO

    Joined:
    May 23, 2013
    Posts:
    115
    Hi,

    Just bought the plugin and wanted to check if this supports desktop builds?

    Thanks
     
  33. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
  34. nw-admin

    nw-admin

    Joined:
    Jun 17, 2010
    Posts:
    53
    Hello Stans,
    This plugin will track EVENTS?
     
  35. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Yep, absolutely.
     
  36. agora

    agora

    Joined:
    Apr 12, 2014
    Posts:
    23
    Hello, I am using the google analytics asset in two games already distributed and it is working great, thanks!
    I would like to enable demographics, to collect more data on users so i can better target ads.

    Google analytics website has this to say:
    Your Demographics and Interest Reports have been enabled, but your Analytics tracking code does not include the necessary support to show them. Learn more about the simple, one-line, one-time change to your tracking code to add this support.

    How can i enable it in the asset?
    Thanks!

    --
    To enable Display Advertising features for iOS, collect the IDFA (Identifier for Advertisers). To enable IDFA collection, link the libAdIdAccess.a and AdSupport.framework libraries to your application and set the allowIDFACollection to YES on each tracker that will collect the IDFA. For example:

    // Assumes a tracker has already been initialized with a property ID, otherwise
    // getDefaultTracker returns nil.
    id tracker = [[GAI sharedInstance] defaultTracker];

    // Enable IDFA collection.
    tracker.allowIDFACollection = YES;

    --
     
  37. HoMeBoYErik

    HoMeBoYErik

    Joined:
    Mar 12, 2014
    Posts:
    23
    Hi,
    great asset indeed. I'm using Unity 4.5.5p3 and I have no problems with iOS and Android but I couldn't put it to work on WebPlayer. I have a couple of questions about web-player build:
    1) does the property in google analytics has to be set up as website or does it work with mobile application as well? (I ask this because I would like to receive analytics from apps and from webplayer all together). I tried with both setup (website and app) but it doesn't work
    2) I used the template for the webplayer that comes with your asset and I can see in the browser console that the plugin create an object with data and send to "posttestserver.com". I guess to make some kind of reflection of the data...like this

    Code (CSharp):
    1. Object {v: "1", tid: "UA-4652519-5", cid: "OIVCUXEYF6F30DC1-C901-5CAC-BCD7-CBD8153BF8C9", an: "Wikisen+Quiz", av: "1.0"} GoogleAnalyticsUnityPlugin.js:7
    2. Successfully dumped 2 post variables.
    3. View it at http://www.posttestserver.com/data/2014/11/05/GA/00.36.421373822149
    is it the correct behaviour?
    3) Am I missing something to put the plugin to work in webplayer?

    Thank you so much
     
  38. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
  39. HoMeBoYErik

    HoMeBoYErik

    Joined:
    Mar 12, 2014
    Posts:
    23
    That fixed the problem. Thank you. Please consider updating the assets or note it in the online doc.
     
  40. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    The asset is already updated, thanks again for the report.
    Cheers!
     
  41. _Adriaan

    _Adriaan

    Joined:
    Nov 12, 2009
    Posts:
    481
    Hey Stanislav,

    With Unity 2.6.0f1, I get the following error when I click the menu item 'Edit Settings'.

    Code (CSharp):
    1. Instance of GoogleAnalyticsSettingsEditor couldn't be created. The script class needs to derive from ScriptableObject and be placed in the Assets/Editor folder.
    It does create the file in the Resources folder, but it's empty. Is there a way I can still get the settings to work?
     
  42. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    wooow. It's pretty old Unity version.

    GoogleAnalyticsSettingsEditor script is inside the Assets/Extensions/GoogleAnalytics/Editor folder. And it's derived from Editor with is Editor from ScriptableObject.

    So I guess path is the issue, probably old Unity version does not support deep Editor folder hierarchy .
    Try to move
    Assets/Extensions/GoogleAnalytics/Editor -> Assets/Editor
    Pretty sure it will help.

    Cheers!
     
  43. PatBGames

    PatBGames

    Joined:
    Mar 28, 2009
    Posts:
    120
    Hi Stanislav,

    I've just bought your asset and it works like a charm in just a few minutes. I'll write a review on the AssetStore after I'll be more used to it.

    +1 for the "testing account" feature, it's a very good idea!

    I've discover that you already manage cached data when offline by reading this forum thread, but it is not in the description and feature list of your asset in the AssetStore, you should update it.

    Keep up the good work :)

    Question: if I understand well the limitations of the webplayer and the security sandbox, you must add javascript code in the html page where the game is hosted to send data to Google. So this plugin won't work for webplayer games hosted on portal sites like Kongregate ? or is there a workaround ?
     
    Last edited: Nov 21, 2014
  44. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Sure will defiantly do this. And thanks for kind words.

    There is work around included in the plugin, basically there is a javascript with will work instead of sending data directly from unity player, have a look:
    https://unionassets.com/google-analytics-sdk/web-player-83

    Cheers!
     
  45. manny003

    manny003

    Joined:
    Mar 18, 2014
    Posts:
    69
    Hi All,

    I just bought the latest version and am trying to use with with Unity 4.5.5. All my coding in Unity up to this time has all been in Javascript so I'm at a lost as to how to use the plug in.

    I've successfully performed set-up and have initialized by performing "Window → Google Analytics → Create Analytics GameObject"

    But I've been unable to successfully perform something like "SendPageHit".

    Does anyone have some Javascript based examples they can share?

    Thanks,
    Manny
     
  46. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
  47. manny003

    manny003

    Joined:
    Mar 18, 2014
    Posts:
    69
    Thanks for the link. I think I got it working -- at least it no longer throws an error and my Debug.Log entries confirms the flow.

    But I've not seen anything record in my Google Analytics account.

    How does Test/Prod work? Am I supposed to simply just create two Properties in my Google Analytic account - one for Test and another for Prod? Or is there something deeper going on?

    I am developing an iOS app for iPhone and iPad -- can test in the Unity Player in my OSX desktop? I tried to send some ScreenHits but it's been over 4 hours and there's nothing on my reports. How long does a recording take before it appears in my online analytic reports?

    I'm not supposed to download and install the iOS Analytics SDK from Google as well, am I?

    Sorry for spamming so many questions but without seeing anything -- I'm not sure where to go.

    Thanks,
    Manny
     
    Last edited: Dec 1, 2014
  48. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Well, you have reasonable questions I will create the guide tomorrow and share the link with you.
     
  49. manny003

    manny003

    Joined:
    Mar 18, 2014
    Posts:
    69
    Thanks. I look forward to your next posting.
     
  50. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790