Exemple #1
0
    // Events

    /*
     * googleAnalytics.LogEvent("Achievement", "Unlocked", "Slay 10 dragons", 5);
     *
     * //Builder Hit with all Event parameters
     * googleAnalytics.LogEvent(new EventHitBuilder()
     * .SetEventCategory("Achievement")
     * .SetEventAction("Unlocked")
     * .SetEventLabel("Slay 10 dragons")
     * .SetEventValue(5));
     *
     * //Builder Hit with minimum required Event parameters
     * googleAnalytics.LogEvent(new EventHitBuilder()
     * .SetEventCategory("Achievement")
     * .SetEventAction("Unlocked"));
     **/

    /* Exceptions
     * public void LogException(string exceptionDescription, bool isFatal);
     *
     * googleAnalytics.LogException("Incorrect input exception", true);
     *
     * //Builder Hit with all Exception parameters
     * googleAnalytics.LogException(new ExceptionHitBuilder()
     * .SetExceptionDescription("Incorrect input exception")
     * .SetFatal(true));
     *
     * //Builder Hit with minimum required Exception parameters
     * googleAnalytics.LogException(new ExceptionHitBuilder());
     * */

    /*
     * Timings
     *
     * googleAnalytics.LogTiming("Loading", 50L, "Main Menu", "First Load");
     *
     * //Builder Hit with all Timing parameters
     * googleAnalytics.LogTiming(new TimingHitBuilder()
     * .SetTimingCategory("Loading")
     * .SetTimingInterval(50L)
     * .SetTimingName("Main Menu")
     * .SetTimingLabel("First load"));
     *
     * //Builder Hit with minimum required Timing parameters
     * googleAnalytics.LogTiming(new TimingHitBuilder()
     * .SetTimingCategory("Loading"));
     * */

    /* Social
     *
     * googleAnalytics.LogSocial("twitter", "retweet", "twitter.com/googleanalytics/status/482210840234295296");
     *
     * //Builder Hit with all Social parameters (all parameters required)
     * googleAnalytics.LogSocial(new SocialHitBuilder()
     * .SetSocialNetwork("Twitter")
     * .SetSocialAction("Retweet")
     * .SetSocialTarget("twitter.com/googleanalytics/status/482210840234295296"));
     * */

    public void trackTransaction(string productId, string purchaseMethod, float price, string currency)
    {
        if (useGoogleAnalytics && googleAnalyticsTracker != null)
        {
            googleAnalyticsTracker.LogTransaction(productId, purchaseMethod, price, 0.0, 0.0, currency);
        }
        if (useUnityAnalytics)
        {
            UnityAnalytics.Transaction(purchaseMethod + "-" + productId, Convert.ToDecimal(price), currency);
        }
    }