我之前使用过Google Analytics v2,可以使用以下代码发送应用名称,应用版本并设置anbonimize Ip:
m_GaTracker.setAnonymizeIp(true);
m_GaTracker.setAppName("MyRemote");
m_GaTracker.setAppVersion(m_appVersion);
其中m_GaTracker
是Google Analytics跟踪器的一个实例。
我现在正在迁移到V3,但此代码不再有效。我收到此错误:
The method setAnonymizeIp(boolean) is undefined for the type Tracker
如何解决此问题,或者我是否可以使用Google Analytics v3发送这些值?
已经检查this,但它没用!!
答案 0 :(得分:3)
我相信你现在需要使用set
方法。
Tracker tracker = GoogleAnalytics.getInstance(this).getTracker("UA-XXXX-Y");
// Values set directly on a tracker apply to all subsequent hits.
tracker.set(Fields.ANONYMIZE_IP, true);
https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference处有一个字段引用。 (它是为analytics.js编写的,v3分析旨在与之对齐。)
您还可以通过反编译libGoogleAnalyticsServices.jar来查看Fields字符串列表:
public final class Fields
{
public static final String ANONYMIZE_IP = "&aip";
public static final String HIT_TYPE = "&t";
public static final String SESSION_CONTROL = "&sc";
public static final String NON_INTERACTION = "&ni";
public static final String DESCRIPTION = "&cd";
public static final String SCREEN_NAME = "&cd";
public static final String LOCATION = "&dl";
public static final String REFERRER = "&dr";
public static final String PAGE = "&dp";
public static final String HOSTNAME = "&dh";
public static final String TITLE = "&dt";
public static final String LANGUAGE = "&ul";
public static final String ENCODING = "&de";
public static final String SCREEN_COLORS = "&sd";
public static final String SCREEN_RESOLUTION = "&sr";
public static final String VIEWPORT_SIZE = "&vp";
public static final String CLIENT_ID = "&cid";
public static final String CAMPAIGN_NAME = "&cn";
public static final String CAMPAIGN_SOURCE = "&cs";
public static final String CAMPAIGN_MEDIUM = "&cm";
public static final String CAMPAIGN_KEYWORD = "&ck";
public static final String CAMPAIGN_CONTENT = "&cc";
public static final String CAMPAIGN_ID = "&ci";
public static final String EVENT_CATEGORY = "&ec";
public static final String EVENT_ACTION = "&ea";
public static final String EVENT_LABEL = "&el";
public static final String EVENT_VALUE = "&ev";
public static final String SOCIAL_NETWORK = "&sn";
public static final String SOCIAL_ACTION = "&sa";
public static final String SOCIAL_TARGET = "&st";
public static final String TIMING_VAR = "&utv";
public static final String TIMING_VALUE = "&utt";
public static final String TIMING_CATEGORY = "&utc";
public static final String TIMING_LABEL = "&utl";
public static final String APP_NAME = "&an";
public static final String APP_ID = "&aid";
public static final String APP_INSTALLER_ID = "&aiid";
public static final String APP_VERSION = "&av";
public static final String EX_DESCRIPTION = "&exd";
public static final String EX_FATAL = "&exf";
public static final String CURRENCY_CODE = "&cu";
public static final String TRANSACTION_ID = "&ti";
public static final String TRANSACTION_AFFILIATION = "&ta";
public static final String TRANSACTION_SHIPPING = "&ts";
public static final String TRANSACTION_TAX = "&tt";
public static final String TRANSACTION_REVENUE = "&tr";
public static final String ITEM_SKU = "&ic";
public static final String ITEM_NAME = "&in";
public static final String ITEM_CATEGORY = "&iv";
public static final String ITEM_PRICE = "&ip";
public static final String ITEM_QUANTITY = "&iq";
public static final String TRACKING_ID = "&tid";
public static final String SAMPLE_RATE = "&sf";
public static final String JAVA_ENABLED = "&je";
public static final String FLASH_VERSION = "&fl";
public static final String USE_SECURE = "useSecure";
static final String API_VERSION = "&v";
static final String CLIENT_VERSION = "&_v";
static final String USAGE_TRACKING = "&_u";
static final String QUEUE_TIME = "&qt";
static final String HIT_TIME = "&ht";
static final String CACHE_BUSTER = "&z";
static final String GCLID = "&gclid";
static final String DCLID = "&dclid";
static final String GMOB_T = "&gmob_t";
public static final String ANDROID_APP_UID = "AppUID";
分析的android文档可能会好得多。