.withTrackingId(getAnalyticsTag(context)) .withConfig(gaConfig) .withDefaultRequest(new DefaultRequest() .applicationName(context.getString(R.string.app_name)) .applicationVersion(Integer.toString(BuildConfig.VERSION_CODE)) .applicationId(BuildConfig.APPLICATION_ID) .trackingId(getAnalyticsTag(context)) .clientId(Installation.id(context)) .anonymizeIp(context.getResources().getBoolean(R.bool.ga_anonymizeIp))
public DefaultRequest(String hitType, String trackingId, String appName, String appVersion) { hitType(GaUtils.isBlank(hitType) ? Constants.HIT_PAGEVIEW : hitType); trackingId(trackingId); applicationName(appName); applicationVersion(appVersion); clientId(DEFAULT_CLIENT_ID); }
public GoogleAnalyticsBuilder withTrackingId(String trackingId) { defaultRequest.trackingId(trackingId); return this; }
public GoogleAnalyticsBuilder withAppName(String value) { defaultRequest.applicationName(value); return this; }
public GoogleAnalyticsBuilder withAppVersion(String value) { defaultRequest.applicationVersion(value); return this; }
public GoogleAnalyticsBuilder withDefaultRequest(DefaultRequest defaultRequest) { this.defaultRequest = GaUtils.firstNotNull(defaultRequest, new DefaultRequest()); return this; }
@Override public DefaultRequest discoverParameters(GoogleAnalyticsConfig config, DefaultRequest request) { try { if (isEmpty(config.getUserAgent())) { config.setUserAgent(getUserAgentString()); } if (isEmpty(request.userLanguage())) { String region = System.getProperty("user.region"); if (isEmpty(region)) { region = System.getProperty("user.country"); } request.userLanguage(System.getProperty("user.language") + "-" + region); } if (isEmpty(request.documentEncoding())) { request.documentEncoding(System.getProperty("file.encoding")); } } catch (Exception e) { logger.warn("Exception while deriving the System properties for request " + request, e); } return request; }
/** * Processes the custom metrics and adds the values to list of parameters, which would be posted to GA. * * @param request * @param postParms */ protected void processCustomMetricParameters(GoogleAnalyticsRequest<?> request, HttpRequest req) { Map<String, String> customMetricParms = new HashMap<String, String>(); for (String defaultCustomMetricKey : defaultRequest.custommMetrics().keySet()) { customMetricParms.put(defaultCustomMetricKey, defaultRequest.custommMetrics().get(defaultCustomMetricKey)); } Map<String, String> requestCustomMetrics = request.custommMetrics(); for (String requestCustomDimKey : requestCustomMetrics.keySet()) { customMetricParms.put(requestCustomDimKey, requestCustomMetrics.get(requestCustomDimKey)); } for (String key : customMetricParms.keySet()) { req.addBodyParam(key, customMetricParms.get(key)); } }
/** * Processes the custom dimensions and adds the values to list of parameters, which would be posted to GA. * * @param request * @param postParms */ protected void processCustomDimensionParameters(GoogleAnalyticsRequest<?> request, HttpRequest req) { Map<String, String> customDimParms = new HashMap<String, String>(); for (String defaultCustomDimKey : defaultRequest.customDimensions().keySet()) { customDimParms.put(defaultCustomDimKey, defaultRequest.customDimensions().get(defaultCustomDimKey)); } Map<String, String> requestCustomDims = request.customDimensions(); for (String requestCustomDimKey : requestCustomDims.keySet()) { customDimParms.put(requestCustomDimKey, requestCustomDims.get(requestCustomDimKey)); } for (String key : customDimParms.keySet()) { req.addBodyParam(key, customDimParms.get(key)); } }
public DefaultRequest(String hitType, String trackingId, String appName, String appVersion) { hitType(GaUtils.isBlank(hitType) ? Constants.HIT_PAGEVIEW : hitType); trackingId(trackingId); applicationName(appName); applicationVersion(appVersion); clientId(DEFAULT_CLIENT_ID); }
public GoogleAnalyticsBuilder withTrackingId(String trackingId) { defaultRequest.trackingId(trackingId); return this; }
public GoogleAnalyticsBuilder withAppName(String value) { defaultRequest.applicationName(value); return this; }
public GoogleAnalyticsBuilder withAppVersion(String value) { defaultRequest.applicationVersion(value); return this; }
public GoogleAnalyticsBuilder withDefaultRequest(DefaultRequest defaultRequest) { this.defaultRequest = GaUtils.firstNotNull(defaultRequest, new DefaultRequest()); return this; }
@Override public DefaultRequest discoverParameters(GoogleAnalyticsConfig config, DefaultRequest request) { try { if (isEmpty(config.getUserAgent())) { config.setUserAgent(getUserAgentString()); } if (isEmpty(request.userLanguage())) { String region = System.getProperty("user.region"); if (isEmpty(region)) { region = System.getProperty("user.country"); } request.userLanguage(System.getProperty("user.language") + "-" + region); } if (isEmpty(request.documentEncoding())) { request.documentEncoding(System.getProperty("file.encoding")); } } catch (Exception e) { logger.warn("Exception while deriving the System properties for request " + request, e); } return request; }
/** * Processes the custom metrics and adds the values to list of parameters, which would be posted to GA. * * @param request * @param postParms */ protected void processCustomMetricParameters(GoogleAnalyticsRequest<?> request, HttpRequest req) { Map<String, String> customMetricParms = new HashMap<String, String>(); for (String defaultCustomMetricKey : defaultRequest.custommMetrics().keySet()) { customMetricParms.put(defaultCustomMetricKey, defaultRequest.custommMetrics().get(defaultCustomMetricKey)); } Map<String, String> requestCustomMetrics = request.custommMetrics(); for (String requestCustomDimKey : requestCustomMetrics.keySet()) { customMetricParms.put(requestCustomDimKey, requestCustomMetrics.get(requestCustomDimKey)); } for (String key : customMetricParms.keySet()) { req.addBodyParam(key, customMetricParms.get(key)); } }
/** * Processes the custom dimensions and adds the values to list of parameters, which would be posted to GA. * * @param request * @param postParms */ protected void processCustomDimensionParameters(GoogleAnalyticsRequest<?> request, HttpRequest req) { Map<String, String> customDimParms = new HashMap<String, String>(); for (String defaultCustomDimKey : defaultRequest.customDimensions().keySet()) { customDimParms.put(defaultCustomDimKey, defaultRequest.customDimensions().get(defaultCustomDimKey)); } Map<String, String> requestCustomDims = request.customDimensions(); for (String requestCustomDimKey : requestCustomDims.keySet()) { customDimParms.put(requestCustomDimKey, requestCustomDims.get(requestCustomDimKey)); } for (String key : customDimParms.keySet()) { req.addBodyParam(key, customDimParms.get(key)); } }