How to get clientId in Android Google Analytics V4?

纵饮孤独 提交于 2019-12-19 04:09:39

问题


I am trying to get the automatically set Analytics clientId in Android. (Setting it is explained in the Android API documentation as setClientId())

When I try to use tracker.get("clientId") it returns empty. Any idea anyone?

Thanks in advance!


回答1:


I've ran a decompiler on it for you and it seems like the clientId property is stored with the key "&cid".

Internally it does this:

set("&cid", clientId);

The solution would be to call this:

tracker.get("&cid");

The get() method does however have special logic for the client ID key. It might also return a newly generated key or throw an InterruptedException like "ClientId loading or generation was interrupted" or an ExecutionException "Failed to load or generate client id"

You can solve these kinds of issues yourself in Android Studio (or IntelliJ IDEA) by installing the "Java Bytecode Decompiler" or "Java Decompiler IntelliJ Plugin" plugins. This allows you to find the Tracker.class symbol and view it as if it was a Java regular file.



来源:https://stackoverflow.com/questions/31674013/how-to-get-clientid-in-android-google-analytics-v4

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