Google Analytics Unity Not Sending Hits

痞子三分冷 提交于 2020-01-07 06:18:10

问题


Does anyone have experience of working with the Unity Google Analytics Plugin? So far I've had no luck at all in sending hits.

The method I'm using is to place the initialised GAv3 prefab into Assets/Resources and then to use this code attached to the camera in each scene to instantiate it and send the screen name.

gav=(Instantiate(Resources.Load("GAv3")) as GameObject).GetComponent.<GoogleAnalyticsV3>();
gav.StartSession();
gav.LogScreen(Application.loadedLevelName);
gav.DispatchHits();

In verbose mode logcat shows:

Initializing Google Analytics 1.0.

Initializing Google Analytics Android Tracker.

Logging Screen.

but I don't see anything arriving in the view either in real time or if I wait 48 hrs.

Am I missing something? Is my approach wrong?


回答1:


OK the answer to my 2 questions are: Yes and No.

I was missing something and there is nothing wrong with my approach.

What was worrying me was that the instantiate approach might be causing the problem as it isn't the method described in the documentation. It turns out that this was not the problem.

What was the problem was lazy copying and pasting. When I copied the tracking code from the GA website I accidentally also copied the line below. When this was copied into the single line textbox for the variable in the inspector the tracking code showed as expected but there was a hidden line that was also part of the string variable that couldn't be seen.

Slap me.

Hopefully this lesson learned helps another careless idiot avoid the same or similar mistake.



来源:https://stackoverflow.com/questions/30589450/google-analytics-unity-not-sending-hits

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!