Integration Issues Troubleshooting

Having issues with your Analytics integration? Please review these suggestions to troubleshoot.

5.2 Integrations

error CS0103: The name ‘Analytics’ does not exists in the current context
This error typically occurs when you are working offline or have Analytics disabled. You can use the UNITY_ANALYTICS compilation define to surround your Analytics calls which will only cause Analytics to be compiled with your project when Analytics is Enabled and it will also remove these errors from the console in the editor.

Not seeing your Custom Events in the Validator
If you are not seeing your Custom Event recorded in the Validator be sure that they are not contained within any of the application startup or shutdown functions. For example, Awake(), Start(), OnApplicationQuit(), etc

You can also test whether Analytics is currently running in your game by writing the event call directly to the Console.

Debug.Log (Analytics.CustomEvent (“TestEvent”, new Dictionary<string, object>{ {“firstObject”, 10 } }));

If ‘OK’ is returned then Analytics is running and your event was successfully sent. If ‘NotInitialized’ is returned then Analytics is not running and your event was not sent.

SDK Integrations

Development Build (applicable for SDK 1.9.1 and higher)
Analytics events are always sent to the Validator from the Editor with no additional configuration needed. To send events to the Validator from a device build (iOS / Android / etc), ensure your build enables the “Development Build” option (File > Build Settings … > Platform > Build Settings).

1 Like

I’m having an issue with this and unity ads.

as of 5.2 we no longer need to download an SDK? can you confirm this?
“The name Analytics does not exist in the current context”
and yes I have “using UnityEngine.Analytics”

Yes. In 5.2 Analytics is built right into Unity. There’s no SDK (so if you’re using the SDK from before, please remove it). You do need to turn on Analytics in the Services Window, which is a little “Cloud” button in the upper right of of Unity.

I see one event in our dashboard after enabling Analytics for our Unity project but nothing from anyone else running the app in the Editor or from our builds (currently just PC) since. Do we need to enable that “Development Build” checkbox under the Platform Build Settings?

No need to enable “Development Build”. I can see a fair number of events in your validator (no custom events, if that’s what you’re looking for). Can you be more specific about what you’re not seeing that you think you should be seeing?

Hello,

I get this error when i tried to build for Android (still didint test for iOS yet) “Assets/Plugins/UnityAnalytics/AndroidWrapper.cs(9,41): error CS0246: The type or namespace name `BasePlatformWrapper’ could not be found. Are you missing a using directive or an assembly reference?”

How to fix it please ?

Thanks

Hi @SIV ,

Which version of Unity are you using? Are you using the downloadable Analytics plugin or engine integrated Analytics found in the Services window?

Hello,

Im using Unity 5.3.1, i downloadede the plugin then later used the integrated service, im i doing it wrong ? after i download it i didint find any configuration, so i thought i need to use the one in services.

@SIV ,

The downloadable plugin will only work with the editor up to version 5.1. For 5.2 and onwards you must enable Analytics through the Services window. There is also one more thing to take note of, for the engine integrated Analytics, 5.2 - 5.3, a call is Analytics.CustomEvent() but for the downloadable plugin it is UnityAnalytics.CustomEvent().

Can you please try removing the downloaded plugin, turning Analytics on in the Services window, creating/linking your project to an Analytics project, double check that your code is formatted correctly, and then let me know what the result is?

1 Like

Yes it works now thank you :smile:

1 Like

I am using Unity 5.3.1 and Analytics has been enabled through the Services window. I am trying to add custom event to my code on Javascript for Android, but get the next error:

‘CustomEvent’ is not a member of ‘UnityEngine.Analytics’

Example code below:

#pragma strict
import System.Collections.Generic;
//import UnityEngine.Analytics;

static function SetGameOverStats(levelNo: int, time: int)
{
var d: Dictionary.<String,Object> = new Dictionary.<String,Object>();

d.Add(“LevelNo”, levelNo);
d.Add(“Time”, time);

Analytics.CustomEvent(“GameOver”, d); // ERROR HERE
}

Hi @geliosoft ,

I believe you need to add another ‘Analytics.’ to the beginning of your call so it looks like, Analytics.Analytics.CustomEvent(“GameOver”, d);

Here is link to some JavaScript examples, Analytics JavaScript Examples - Unity Services - Unity Discussions

One question: will the availability check be changed in the future?
I like the easy integration of the anaylitcs plugin, but user management and availability checks are horrible. Currently we set every people in the team of our organization to “owners”, just to avoid the next compilation problem with the plugin. Other plugins handle availability checks in the plugin itself and hide it from the user. I would prefer that also for UA, though I guess that component and code stripping are one of the reasons why it is not done yet.

Hi @pahe ,

Can you please elaborate a little bit on what you mean by availability check? Also, what compilation problems you were running into?

Sure.

We’ve got some trouble when new people are checking out the project. When the project tries to compile, it often fails as it can’t compile the UA libraries as it is turned off. Even adding the people to our organization as members is not sufficient sometimes, as they don’t have the “permission” to turn it on again, which is “strange” as it is already active for all other people.
Only solution is to logout with the current account, login with another account who is admin, enable the UA option, log out and login with the new user.

So, by availability check I mean, the check if UA is enabled or not is somehow flawed/buggy and is not received correctly from the Unity cloud (I guess there is somewhere the information stored).

From other plugins, I know that they still compile, even if the plugin is not supported on a specific platform and this is something I would also like to see with UA.

Hi @pahe ,

I believe that all users should be able to turn Analytics on and off. Can you fill out a support ticket and send me a screenshot of your organization overview (found in My Organizations → manage/the cog image → Members) and the emails of a couple of the users not able to toggle analytics on and off? Also which version of the editor you are using.

Until we are able to figure out what is going on with the accounts, our current recommendation for availability checks is to surround your analytics code with if defined statements, as described in first post on this page, so that it is only included when Analytics is on. This should allow the project to compile, even when Analytics is off.

@erika_d
Ok, I’ll try to reproduce it again and create a ticket for you. Due to this, I already modified our code with the define statemens (found this thread when I was searching for a solution :slight_smile: ).

1 Like

@sschan Is the following still true?
While we are in Beta we have set a limit to the number of parameters a single Custom Event can have to 10. If you are sending more parameters in a Custom Event this is most likely the cause of your events not being received by the Validator.

I am having trouble finding documentation that mentions a Validator and/or how to trouble shoot when things are not working. Can you provide a link that goes into more detail? I am searching through the forums but this is not ideal.

What I am experiencing: I have custom events defined with the names: PlayerDied, PlayerQuit, PlayerResart, EndLevel 0 Thread 1. I believe these are being sent correctly as I can see some of them in the Support/Integration/Custom Events page but these do not appear in the Data Explorer.

I do see the unity.sceneLoad custom event but I did not create this. Is there any documentation around what this is and what it means. I can guess but the parameters all have the same value and do not have any real meaning to my game.

Hi @chilberto ,

If you are seeing events logged on the Integration pages then they should also populate on the Data Explorer page after approximately 6 hours. If it has been over 6-8 hours would you mind opening a support ticket with your project id here, Unity Cloud so that I can take a look into this?

“be sure that they are not contained within any of the application startup or shutdown functions. For example, Awake(), Start(), OnApplicationQuit(), etc”

Am I reading this wrong? Can we really not put analytics code in Start or Awake methods? I would like custom events when the app starts (not reliant on any user input). Is that possible, and how? Thanks!