Search Unity

Google Analytics Mobile Plugin [Released] [Free]

Discussion in 'Assets and Asset Store' started by DavidJNels, Jun 29, 2013.

  1. heliorunner

    heliorunner

    Joined:
    Apr 27, 2013
    Posts:
    4
    That is a great news. I was using this plugin for few month already, and this is cool to have the ability to get app linked to Google Analytics. Simple and very usefull, congratulations!
     
  2. nickthegreek

    nickthegreek

    Joined:
    Jan 31, 2014
    Posts:
    12
    Thank you very much for this great plugin. I am using this plugin to my new Android game and it works fine! Great job guys. Analytics is such an important tool to understand game performance and reception.

    Is it too dificult to add support for events as well? It will help us understand our gamer behaviour even better.

    Thank you very much!
     
  3. vanderFeest

    vanderFeest

    Guest

    I've adapted the script to become a real singleton with static methods to post Events, Transactions, Social and Session start/end, although the last part doesn't work well on iPhone since it doesn't seem to have enough time to send out the request.

    Also, it now uses POST requests, and tries to set the right User-Agent header for iOS (also work in progress, not functional yet)

    It's not perfect yet, just a bit of improvement.

    I didn't implement callbacks, since I didn't think anyone wants their game to be burdened with them? Analytics don't need to be perfect, but they do need to be quick.

    Usage is still simple:
    - Create empty GameObject in first loaded scene (call it Analytics for future clarity if you like)
    - Add GoogleAnalytics Script to this GameObject
    - Fill in the right values at the script
    - Use the following functions anywhere in your code to post triggers:
    Code (csharp):
    1.  
    2. GoogleAnalytics.StartSession();
    3. GoogleAnalytics.EndSession();
    4.  
    ^^ These are already called automatically on start and exit, as well as a lot of device info on start

    Code (csharp):
    1.  
    2. GoogleAnalytics.LogScreen(string title);
    3. GoogleAnalytics.LogEvent(string action, string category (optional), string label (optional));
    4. GoogleAnalytics.LogTransaction(string id, float revenue (optional), string currency (optional), string affiliation (optional), string item (optional), int quantity (optional);
    5. GoogleAnalytics.LogSocial(string network, string action, string target);
    6.  
     

    Attached Files:

    d12frosted likes this.
  4. the_pheNom

    the_pheNom

    Joined:
    Jun 7, 2014
    Posts:
    1
    im very new to this... so pls forgive my ignorance..
    vanderFeest ... im using ur code to implement GA

    i want to record a logscreen
    i hit a button n enter the lobby
    so on hitting the button ... i do GoogleAnalytics.LogScreen("Lobby");

    in GA it says active screen name = 1. (not set) :/
    PLS HELP!!

    m i missing something??
     
  5. rferrez

    rferrez

    Joined:
    Mar 22, 2014
    Posts:
    1
    Hi,

    Thanks for this plugin, works like a charm. I've just included it in my new game made with Unity (Run to 2048 Tile for those interested, a hardcore mode of 2048 & White Tile or sort of...).

    I've just made a quick change for proper iOS trafic tracking (I haven't tested vanderFeest version of this Plugin, as it seems to be still a work in progress), here's the code snippet :

    Code (CSharp):
    1.  
    2. #if UNITY_IPHONE
    3.     Dictionary<string, string> headers = new Dictionary<string, string>();
    4.     headers.Add("User-Agent", string.Format("{0}/{1} ({2}; {3} like Mac OS X) ", bundleID.Substring(bundleID.LastIndexOf(".") + 1), appVersion,    SystemInfo.deviceModel.Substring(0, SystemInfo.deviceModel.Length - 3), SystemInfo.operatingSystem.Replace(".", "_")));
    5.     WWW request = new WWW(url, null, headers);    
    6. #else
    7.     WWW request = new WWW(url);
    8. # endif    
    Tested on iPhone & iPad, not on iPod touch yet. This User-Agent is simplified, but it's built like the one on Android and Google Analytics seems to classify trafic as expected.
     
    Last edited: Jun 24, 2014
  6. coldwar98

    coldwar98

    Joined:
    May 31, 2014
    Posts:
    1
    Hey DavidJnels first thx for sharing script.
    But as i did as per instruction above and i cant get any output from it , google analytic website does not show any data may be i am mising some step plz help me i am in trouble.
    it will be helpfull if u make a quick video about it. plz.
     
  7. d12frosted

    d12frosted

    Joined:
    Feb 3, 2014
    Posts:
    43
    Thank you very much for your implementation of GoogleAnalitycs.
     
  8. Kutalp

    Kutalp

    Joined:
    Jul 20, 2014
    Posts:
    1
    Code (CSharp):
    1. // Reports that the user is viewing the Main Menu
    2.     if (GoogleAnalytics.instance)
    3.     GoogleAnalytics.instance.LogScreen("Main Menu");
    where this code will add ? and i will chance Main Menu with what ?
     
  9. casperjeff

    casperjeff

    Joined:
    Apr 13, 2013
    Posts:
    333
    Thanks MILLIONS for this technique...
    Watching LIVE analytics info while my beta testers were playing was AWESOME!!
    I could tell what mission they were on, what missions they had completed - how long they took on each mission - and then the more obvious stuff - devices, resolution, geolocation, etc.

    Kudos!
     
  10. gboistar

    gboistar

    Joined:
    Jul 21, 2014
    Posts:
    3
    Hi guys,
    Could you tell me how to implement your plugin without forcing READ_PHONE_STATE permission?

    In your code there is
    Code (CSharp):
    1. SystemInfo.deviceUniqueIdentifier
    for the ClientID which force permission "READ_PHONE_STATE". This kind of permission scares some users and from what I know it returns device IMEI.

    Is there some equivalent for deviceUniqueIdentifier to distinguish users without forcing this permission?
    Maybe other guys had similar issue?
     
  11. casperjeff

    casperjeff

    Joined:
    Apr 13, 2013
    Posts:
    333
    Hmm....must be that when in 'beta' mode on Google Play - it doesn't show you the REAL permissions required for the app/game...
    So I hadn't noticed. I assumed 'internet access' permissions - but hadn't counted on the READ_PHONE_STATE. Not sure if my users will care - but curious as to response as well.

    1.png
     
  12. Krishx007

    Krishx007

    Joined:
    Jul 15, 2014
    Posts:
    4
    Good Job, Thanx for sharing!!!!
     
  13. marcelotk

    marcelotk

    Joined:
    May 24, 2012
    Posts:
    7
    Great plugin! Thank you for sharing!
     
  14. shadab_badar

    shadab_badar

    Joined:
    Aug 2, 2013
    Posts:
    3
    Does This supports windows mobile platform also??
     
  15. maria-dev

    maria-dev

    Joined:
    Sep 19, 2014
    Posts:
    10
    Thats great :)
     
  16. longkeng

    longkeng

    Joined:
    Sep 2, 2014
    Posts:
    16
    Last edited: Mar 23, 2015
  17. Maximyz

    Maximyz

    Joined:
    Jun 8, 2013
    Posts:
    8
    Hi!

    First, thank you for great plugin! It worked perfect untill i have changed language of appname. It is not works now.

    How can I fix it?
     
  18. Bafelmauk

    Bafelmauk

    Joined:
    Apr 1, 2015
    Posts:
    1
    Hello i have small problem also
    when i but this code under refresh
    1. // Reports that the user is viewing the Main Menu
    2. if (GoogleAnalytics.instance)
    3. GoogleAnalytics.instance.LogScreen("Main Menu");
    this give me lot data but i think it's wrong ?
    should i put this under start ?
    or where i should put this code ?
    and when i change screen then it say me still that same screen
    like 2 screen "Main" and "Shop"
    when i go main to shop it still say me Main
    please help
     
  19. squarelover

    squarelover

    Joined:
    Nov 14, 2012
    Posts:
    8
    bought/integrated/getting this on android kitkat unity 4.7

    I/Unity (17982): AN: Using proxy for class: com.androidnative.analytics.ReferalIntentReciever method:RequestReferrer

    I/Unity (16963): IndexOutOfRangeException: Array index is out of range.

    I/Unity (16963): at GoogleAnalytics.OnReferalIntentReciver (System.String referrerString) [0x00000] in <filename unknown>:0

    here:
    at GoogleAnalytics.OnReferalIntentReciver(string referralstring)
    int urlBeginIndex = referrerString.LastIndexOf('?');
    logged referralString shows as null
     
  20. Deathfate

    Deathfate

    Joined:
    Sep 10, 2012
    Posts:
    46
    I have ultimate mobile and Im having an issue with campaing reciever. Whe I use the command in the adb I get this error:

    java.lang.RuntimeException: Unable to instantiate receiver com.androidnative.analytics.ReferalIntentReciever: java.lang.ClassNotFoundException: Didn't find class "com.androidnative.analytics.ReferalIntentReciever"

    It seesm like I am missing some library but I cannot find where it is...
     
unityunity