Search Unity

Add Google Analytics to your project

Discussion in 'Scripting' started by ElmarKleijn, Aug 4, 2010.

  1. dtarules

    dtarules

    Joined:
    Sep 17, 2012
    Posts:
    2
    same here! any idea?
     
  2. brumble

    brumble

    Joined:
    Aug 24, 2012
    Posts:
    4
    Hi, May I know if you have used TimViana or azeitler final version or almar's original code to get them working for android unity game? As I tried all 3, the real time function isn't working at all. Thank you for your help!

    I managed to get this output:

    [Google URL]http://www.google-analytics.com/__utm.gif?utmwv=1&utmn=1795908746&utmhn=127.0.0.1&utmsr=1280x800&utmul=nl&utmdt=TestV1.4&utmr=-&utmp=TestV1.4&utmac=UA-xxxxxxxx-x&utmcc=__utma%3D19432783.1795908746.1352509761.1352509761.1352509761.21.10%3b%2b__utmz%3D19432783.13525097612.2.2.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3b&utme=5(Progress*GameOver*Distance_Travelled)(19)&utmt=event
    UnityEngine.Debug:Log(Object)
    GoogleAnalyticsHelper:LogEvent(String, String, String, String, Int32) (at Assets/3_Scripts/Globals/GoogleAnalyticsHelper.cs:273)
    Runner:Update() (at Assets/3_Scripts/Runner/Runner.cs:151)

    Is this the desired output and link?
     
    Last edited: Nov 9, 2012
  3. brumble

    brumble

    Joined:
    Aug 24, 2012
    Posts:
    4
    any kind soul out there that would help with this issue? GA is not reflecting anything after 24 hours and I've been trying all combination of settings. I would really appreciate your help!
     
  4. FiveFingers

    FiveFingers

    Joined:
    Oct 15, 2009
    Posts:
    541
    Also I don't get it how can work with iOS, there is a SDK to download that is Obj-C code for Google Analytics, is this trying to use the website Analytics feature on an app ? I don't know if it will work on iPhone/iPad
     
  5. helios

    helios

    Joined:
    Oct 5, 2009
    Posts:
    308
    Did you ever get this working?
     
  6. AryanBina

    AryanBina

    Joined:
    Dec 25, 2012
    Posts:
    3
    Hi Guys.

    It would Help if anyone can post a step by step tutorial for enabling google analytics in IOS mobile apps using the above script.
    i dont understand what is the domain and if i need the sdk for this script to work !!

    tnx in advance

    Aryan
     
  7. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    Well I've tried everything and still get nothing showing on Google Analytics. I've tried it in IOS and Android but nada!
    I'm sure it must be something to do with the domain part of the code as it's the only bit not made clear by any of htese posts. Just what exactly should the domain be? I've not set one up anywhere so just used my web site domain but this doesn't seem to make sense to me. Where excatly on google do I set the domain and what shoud it look like in the code?

    Has anyone as of today got this working on Android or IOS? I'm about to give up with google analytics and try something else, maybe even my own server as at least then I can see the data comming in or not!
     
  8. LemonPepper

    LemonPepper

    Joined:
    Sep 21, 2011
    Posts:
    20
    When trying to attach the script from Almar to a prefab, Unity won't allow it saying it has to derive from Monobehavior. If I change the class to public class GoogleAnalyticsHelper : MonoBehaviour, I get a caution: You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Etc.

    Any ideas on what I need to do to get this working? Thanks.
     
  9. Thormor

    Thormor

    Joined:
    Nov 22, 2012
    Posts:
    39
    Did anyone was able to make it work with Google Analytic App profile instead of the web one?
     
  10. Ross_S

    Ross_S

    Joined:
    Jul 10, 2012
    Posts:
    29
    Hey if anybody on this thread could help me that would be amazing...

    basically - i'm not sure what the 'domain' setting should be.
    It's an IOS Flash Unity app.... if i set the domain to '127.0.0.1' -
    do i then need to set up that domain on my Google Analytics profile? Can't seem to find a place to set that domain up? (it's an App not web profile)

    i'm doing the WWW calls and seeing nothing at all in the real-time overview page on the google analytics site.. that's basically the problem.
    any clues?
    should it work from the player or do i need to run actual flash/iphone versions?
    thanks :)
     
  11. Thormor

    Thormor

    Joined:
    Nov 22, 2012
    Posts:
    39
    I was not able to make it work with the APP profile but with Web profile it's working. However every LogEvent I am doing is calculated as a new active user...
     
  12. Soundguy

    Soundguy

    Joined:
    Oct 30, 2009
    Posts:
    49
    so what paremeters should you change in the script to make it behave like an app rather than a website?
     
  13. oferei

    oferei

    Joined:
    Dec 1, 2012
    Posts:
    36
    Yes. I just finished integrating the Android SDK. Wrote a post about it (link).

    Note that this method does not use the web API. It uses Google Analytics for Mobile which is more suitable for mobile apps. You can send screen names, events, crash reports, device information, timings and more.
     
    Last edited: Jul 18, 2013
  14. Sounds-Wonderful

    Sounds-Wonderful

    Joined:
    May 15, 2013
    Posts:
    106
    How do I read from GA using this class for instance how many are currently on the website etc.?
     
  15. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    I'd like to mention my solution for integrating Google Analytics to Unity projects:
    Google Universal Analytics in Asset Store.
    (Website / forum thread)

    Google's new Universal Analytics has a "measurement protocol" specification, and the above package uses that to send hits to analytics. The advantage here is that there's no need for native library for each platform. So the same code actually works on mobile, desktop and web player platforms (Desktop - Windows, OSX, Linux, Windows8; Mobile - iOS, Android, Windows Phone 8, BlackBerry 10; Browser - Unity Web Player plugin). It's implemented in pure C# and uses Unity's WWW class for networking.
     
    Last edited: Dec 20, 2013
  16. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    If you're still looking for a solution like this, see my previous reply above -- my Google Universal Analytics package in asset store has all the needed hacks to make analytics work also with the web player. (shameless plug, I know)
     
  17. Bezzy

    Bezzy

    Joined:
    Apr 1, 2009
    Posts:
    75
    I'm trying to send the optional value for an event, and although the event is being noticed on analytic's realtime feed, the value is always appearing as 1, no matter what the (unsigned) input. Code is:

    Code (csharp):
    1.  
    2.             Analytics.gua.beginHit(GoogleUniversalAnalytics.HitType.Event);
    3.         Analytics.gua.addEventCategory ("GamePlay");
    4.         Analytics.gua.addEventAction ("GameOver");
    5.         Analytics.gua.addEventLabel ("sunsCollected");
    6.             Analytics.gua.addEventValue(GameEngine.Instance.NumSunsCollected);
    7.         Analytics.gua.sendHit();   
    8.  
    Any idea what might be wrong? Everything else has been pretty smooth, so thanks for this!

    [Edit] Now that a day or so has passed, the values have shown up in analytics, intact! Thank you! I guess it's just that "Real Time" mode doesn't fully process them. I think we're using Google Analytics for things it wasn't really intended for (it doesn't let you histograms the optional label value) but otherwise, we good. Thanks!
     
    Last edited: Feb 19, 2014
  18. Green-Jungle

    Green-Jungle

    Joined:
    Jun 10, 2014
    Posts:
    79
    Last edited: Dec 23, 2014
  19. Mduat

    Mduat

    Joined:
    Jun 13, 2019
    Posts:
    2
    Embed Google Analytics on the site is not difficult. There are many sites with instructions on this. Or you can turn to freelance developers if you want to simplify this process. But you need to introduce Google Analytics. On my main site I use it for a long time. I also have a Twitter account and I recently added tracking traffic using Google Analytics to it. I can send you this instruction www.owox.com/blog/articles/twitter-analysis-in-google-analytics. Good additional information that will not be superfluous.