Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGL: measurement protocol not working correctly #156

Open
vasyaPP opened this issue May 30, 2017 · 0 comments
Open

WebGL: measurement protocol not working correctly #156

vasyaPP opened this issue May 30, 2017 · 0 comments

Comments

@vasyaPP
Copy link

vasyaPP commented May 30, 2017

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".

I fixed it by creating a random guid for clientId class member.

#if UNITY_WEBGL

clientId = PlayerPrefs.GetString(WebglUidKey, string.Empty);

if (clientId == string.Empty) {

  clientId = Guid.NewGuid().ToString();

  PlayerPrefs.SetString(WebglUidKey, clientId);

}

#else

clientId = SystemInfo.deviceUniqueIdentifier;

#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant