Nau
Nau

Reputation: 21

Basic usage of Google Analytics Plugin for Unity3D

I'm trying to get analytics from a mobile app developed in Unity3D using Google Analytics Plugin for Unity. I've tried the simplest program, it doesn't throw errors but 48 hours later there's no data in Google Analytics dashboards. Here's the complete example:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour {
    public GoogleAnalyticsV4 ga;
    public UnityEngine.UI.Text myText;
    private void Start() {
        try {
            ga.StartSession();
            ga.LogScreen("MAIN_SCREEN");
            myText.text = $"<b>No errors</b>";
        }
        catch (Exception e) {
            myText.text = $"<b>{e}</b>";
        }
    }
}

If there's a more suitable option than the Google Analytics Plugin for Unity it would be great to know it.

Any help would be greatly appreciated.

Upvotes: 1

Views: 221

Answers (1)

Nau
Nau

Reputation: 21

Finally I found the error. In google analytics for Unity3D you must have a Universal analytics property (UA-XXXXXXX-1) I always tried it without it and, obviously, it didn't work.

Once you has the object properly initialized in your inspector, you need to create your script to call analytics functions. I don't know if always is needed but I have to call other function in addition to startSession. As the code I pasted in the question I also called a LogScreen and then I started to recieve information in my GoogleAnalytics.

ga.StartSession();
ga.LogScreen("MAIN_SCREEN");

If someone has the same issue I leave here the support page where indicates how get an Universal Analytics property

Upvotes: 1

Related Questions