Reputation: 271
I have added google analytics plugin to my project. When I run it in Unity editor, everything works just fine - I can see 1 person playing on Desktop on Google Analytics website in "Real-time" tab. Next day, I can see all the data in the "Audiences" tab. When I push it into my Android device, it doesn't seem to work at all.
I have tried using logcat with VERBOSE logging set and there are no errors. Here is an example project run:
D/Unity (25299): GL_AMD_compressed_ATC_texture GL_AMD_performance_monitor GL_AMD_program_binary_Z400 GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_robustness GL_EXT_texture_format_BGRA8888 GL_EXT_texture_type_2_10_10_10_REV GL_NV_fence GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_depth24 GL_OES_EGL_image GL_OES_EGL_sync GL_OES_EGL_image_external GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_fragment_precision_high GL_OES_get_program_binary GL_OES_packed_depth_stencil GL_OES_depth_texture_cube_map GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_3D GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_vertex_type_10_10_10_2 GL_OES_vertex_array_object GL_QCOM_alpha_test GL_QCOM_binning_control GL_QCOM_driver_control GL_QCOM_perfmon_global_mode GL_QCOM_extended_get GL_QCOM_extended_get2 GL_QCOM_tiled_rendering GL_QCOM_writeonly_rendering GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_
D/Unity (25299): texture_sRGB_decode GL_EXT_texture_filter_anisotropic GL_EXT_multisampled_render_to_texture GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_EXT_disjoint_timer_query
I/Unity (25299): Initializing Google Analytics 0.1.
I/Unity (25299):
I/Unity (25299): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)
I/Unity (25299):
I/Unity (25299): Initializing Google Analytics Android Tracker.
I/Unity (25299):
I/Unity (25299): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)
I/Unity (25299):
I/Unity (25299): Logging screen.
I/Unity (25299):
I/Unity (25299): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)
I/Unity (25299):
I/Unity (25299): Enabling uncaught exception reporting.
I/Unity (25299):
I/Unity (25299): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)
I/Unity (25299):
I/Unity (25299): Logging screen.
I/Unity (25299):
I/Unity (25299): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)
I/Unity (25299):
I/Unity (25299): Logging screen.
I/Unity (25299):
I/Unity (25299): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)
I/Unity (25299):
I/Unity (25299): Logging screen.
I/Unity (25299):
I/Unity (25299): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)
I/Unity (25299):
I/Unity (25299): Logging event.
I/Unity (25299):
I/Unity (25299): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)
I/Unity (25299):
I/Unity (25299): Logging event.
I/Unity (25299):
I/Unity (25299): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)
I/Unity (25299):
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.app" android:theme="@android:style/Theme.NoTitleBar" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name" android:screenOrientation="fullSensor" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
</activity>
</application>
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="21" />
<uses-feature android:glEsVersion="0x00020000" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>
According to google analytics real time page, noone is playing the game. Thought it might be real-time tab not working with Android devices - next day, there is still no data from Android, just Desktop. Any ideas what could be the cause?
Upvotes: 2
Views: 1821
Reputation: 11
I had the same problem, turned out I had a single white space behind my tracking code in the unity editor.
I would have never found out if it wasn't for this guy: Google Analytics Unity Not Sending Hits
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.
Upvotes: 1