Open vasyaPP opened 7 years ago
I'm using GA plugin in my WebGL game and discovered that sessions and events do not count correctly. After some research I located to the problem place.
Measurement protocol required cid parameter in url. Currently in https://github.com/googleanalytics/google-analytics-plugin-for-unity/blob/master/source/Plugins/GoogleAnalyticsV4/GoogleAnalyticsMPV3.cs#L62 it's defined as clientId = SystemInfo.deviceUniqueIdentifier. But in webgl builds SystemInfo.deviceUniqueIdentifier always equals "n / a".
cid
clientId = SystemInfo.deviceUniqueIdentifier
I fixed it by creating a random guid for clientId class member.
clientId = PlayerPrefs.GetString(WebglUidKey, string.Empty); if (clientId == string.Empty) { clientId = Guid.NewGuid().ToString(); PlayerPrefs.SetString(WebglUidKey, clientId); }
clientId = SystemInfo.deviceUniqueIdentifier;
I'm using GA plugin in my WebGL game and discovered that sessions and events do not count correctly. After some research I located to the problem place.
Measurement protocol required
cid
parameter in url. Currently in https://github.com/googleanalytics/google-analytics-plugin-for-unity/blob/master/source/Plugins/GoogleAnalyticsV4/GoogleAnalyticsMPV3.cs#L62 it's defined asclientId = SystemInfo.deviceUniqueIdentifier
. But in webgl builds SystemInfo.deviceUniqueIdentifier always equals "n / a".I fixed it by creating a random guid for clientId class member.
if UNITY_WEBGL
else
endif