我在 Appengine 中使用 Google Analytics(分析)。 我正在使用以下代码跟踪服务器端事件:
Map<String, String> map = new LinkedHashMap<>();
map.put("v", "1"); // Version.
map.put("tid", gaTrackingId);
map.put("cid", "555");
map.put("t", "event"); // Event hit type.
map.put("ec", encode(category, true));
map.put("ea", encode(action, true));
map.put("el", encode(label, false));
map.put("ev", encode(value, false));
HTTPRequest request = new HTTPRequest(new URL("http", "www.google-analytics.com", "/collect"), HTTPMethod.POST);
request.addHeader(CONTENT_TYPE_HEADER);
request.setPayload(getPostData(map));
HTTPResponse httpResponse = urlFetchService.fetch(request);
// Return True if the call was successful.
return httpResponse.getResponseCode();
最佳答案
我知道这已经很老了,但我也遇到了完全相同的问题。对我来说,解决方法是开始提供通用值为 1 的“可选”事件值 (ev) 参数。一旦我开始这样做,我的所有事件都会立即在非实时 View 中可见。看来我还需要发送“可选”cid 参数,即使我已经发送了 uid 参数,并且文档说即使它们都是“可选”;但需要一个。看来cid参数可能被Google给予了特殊对待。希望对您有所帮助!
关于java - Google 分析事件显示在实时 View 中,但未存档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48052843/