-
Notifications
You must be signed in to change notification settings - Fork 0
API
eason2019tw edited this page Apr 6, 2020
·
6 revisions
Table of Contents
Bundle bundle = new Bundle();
try {
JSONObject jsonObject = new JSONObject();
JSONObject inner_json = new JSONObject();
inner_json.put("inner", "jsonobject");
jsonObject.put("xxx", inner_json);
bundle.putString(OmniAnalytics.PayloadType.EVENT_LABEL, jsonObject.toString());
} catch (JSONException e) {
e.printStackTrace();
}
bundle.putString(OmniAnalytics.PayloadType.EVENT_ACTION, OmniAnalytics.EventActionType.CLICK_MENU);
bundle.putString(OmniAnalytics.PayloadType.EVENT_CATEGORY, "TestCategory");
bundle.putInt(OmniAnalytics.PayloadType.EVENT_VALUE, 123);
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.EVENT, bundle);CompleteRegistration completeRegistration = new CompleteRegistration();
completeRegistration.setBirthdayYear("1994");
completeRegistration.setGender(OmniAnalytics.GenderType.MALE);
completeRegistration.setCity("Taipei");
completeRegistration.setRegType("regType");
Bundle bundle = new Bundle();
bundle.putString(OmniAnalytics.PayloadType.EVENT_CATEGORY, OmniAnalytics.EventCategoryType.COMPLETE_REGISTRATION);
bundle.putString(OmniAnalytics.PayloadType.EVENT_ACTION, OmniAnalytics.EventActionType.COMPLETE_REGISTRATION);
bundle.putSerializable(OmniAnalytics.EventActionType.COMPLETE_REGISTRATION, completeRegistration);
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.EVENT, bundle);Bundle bundle = new Bundle();
bundle.putString(OmniAnalytics.PayloadType.CONTENT_GROUP, "Home");
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.EVENT, bundle);Impression impression1 = new Impression("12345", "Triblend Android T-Shirt");
impression1.setPrice("15.25");
impression1.setBrand("Google");
impression1.setCategory("Apparel");
impression1.setVariant("Gray");
impression1.setList("Search Results");
impression1.setPosition("1");
Impression impression2 = new Impression("123455", "Same list T-Shirt");
impression2.setPrice("15.25");
impression2.setBrand("Google");
impression2.setCategory("Apparel");
impression2.setVariant("Gray");
impression2.setList("Search Results");
impression2.setPosition("2");
Impression impression3 = new Impression("67890", "Donut Friday Scented T-Shirt");
impression3.setPrice("33.75");
impression3.setBrand("Google");
impression3.setCategory("Apparel");
impression3.setVariant("Black");
impression3.setPosition("1");
ArrayList < Impression > arrayList = new ArrayList < > (Arrays.asList(impression1, impression2, impression3));
Bundle bundle = new Bundle();
bundle.putString(OmniAnalytics.PayloadType.CONTENT_GROUP, "default category list");
bundle.putString(OmniAnalytics.PayloadType.CURRENCY_CODE, "TWD");
bundle.putSerializable(OmniAnalytics.DataType.IMPRESSIONS, arrayList);
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.PAGEVIEW, bundle);Product product1 = new Product("product1_name", "product1_id", "10.10", 1);
product1.setBrand("Omni_Brand");
product1.setCategory("Omni_Category");
product1.setVariant("Omni_Variant");
product1.setCoupon("Omni_Coupon");
ArrayList < Product > arrayList = new ArrayList < > (Arrays.asList(product1));
Bundle bundle = new Bundle();
bundle.putString(OmniAnalytics.PayloadType.PRODUCT_ACTION_LIST, "Search Results");
bundle.putString(OmniAnalytics.PayloadType.CURRENCY_CODE, "TWD");
bundle.putString(OmniAnalytics.PayloadType.EVENT_ACTION, OmniAnalytics.EventActionType.CLICK_PRODUCT);
bundle.putSerializable(OmniAnalytics.DataType.PRODUCTS, arrayList);
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.EVENT, bundle);Product product1 = new Product("product1_name", "product1_id", "10.10", 1);
product1.setBrand("Omni_Brand");
product1.setCategory("Omni_Category");
product1.setVariant("Omni_Variant");
product1.setCoupon("Omni_Coupon");
ArrayList < Product > arrayList = new ArrayList < > (Arrays.asList(product1));
Bundle bundle = new Bundle();
bundle.putString(OmniAnalytics.PayloadType.PRODUCT_ACTION_LIST, "category list");
bundle.putString(OmniAnalytics.PayloadType.CURRENCY_CODE, "TWD");
bundle.putSerializable(OmniAnalytics.PayloadType.PRODUCT_ACTION, OmniAnalytics.ActionType.DETAIL);
bundle.putSerializable(OmniAnalytics.DataType.PRODUCTS, arrayList);
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.PAGEVIEW, bundle);Product product1 = new Product("product1_name", "product1_id", "10.10", 1);
product1.setBrand("Omni_Brand");
product1.setCategory("Omni_Category");
product1.setVariant("Omni_Variant");
product1.setCoupon("Omni_Coupon");
ArrayList < Product > arrayList = new ArrayList < > (Arrays.asList(product1));
Bundle bundle = new Bundle();
bundle.putString(OmniAnalytics.PayloadType.CURRENCY_CODE, "TWD");
bundle.putString(OmniAnalytics.PayloadType.EVENT_ACTION, OmniAnalytics.EventActionType.ADD_TO_CART);
bundle.putSerializable(OmniAnalytics.DataType.PRODUCTS, arrayList);
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.EVENT, bundle);Product product1 = new Product("product1_name", "product1_id", "10.10", 1);
product1.setBrand("Omni_Brand");
product1.setCategory("Omni_Category");
product1.setVariant("Omni_Variant");
product1.setCoupon("Omni_Coupon");
ArrayList < Product > arrayList = new ArrayList < > (Arrays.asList(product1));
Bundle bundle = new Bundle();
bundle.putString(OmniAnalytics.PayloadType.CURRENCY_CODE, "TWD");
bundle.putString(OmniAnalytics.PayloadType.EVENT_ACTION, OmniAnalytics.EventActionType.REMOVE_FROM_CART);
bundle.putSerializable(OmniAnalytics.DataType.PRODUCTS, arrayList);
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.EVENT, bundle);Promotion promotion1 = new Promotion("JUNE_PROMO13", "June Sale");
promotion1.setCreative("banner1");
promotion1.setPosition("slot1");
Promotion promotion2 = new Promotion("FREE_SHIP13", "Free Shipping Promo");
promotion1.setCreative("skyscraper1");
promotion1.setPosition("slot2");
ArrayList < Promotion > arrayList = new ArrayList < > (Arrays.asList(promotion1, promotion2));
Bundle bundle = new Bundle();
bundle.putSerializable(OmniAnalytics.DataType.PROMOTIONS, arrayList);
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.PAGEVIEW, bundle);Promotion promotion1 = new Promotion("JUNE_PROMO13", "June Sale");
promotion1.setCreative("banner1");
promotion1.setPosition("slot1");
ArrayList < Promotion > arrayList = new ArrayList < > (Arrays.asList(promotion1));
Bundle bundle = new Bundle();
bundle.putString(OmniAnalytics.PayloadType.EVENT_ACTION, OmniAnalytics.EventActionType.CLICK_PROMOTION);
bundle.putSerializable(OmniAnalytics.DataType.PROMOTIONS, arrayList);
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.PAGEVIEW, bundle);Product product1 = new Product("product1_name", "product1_id", "10.10", 1);
product1.setBrand("Omni_Brand");
product1.setCategory("Omni_Category");
product1.setVariant("Omni_Variant");
product1.setCoupon("Omni_Coupon");
Product product2 = new Product("product2_name", "product2_id", "12.12", 2);
Product product3 = new Product("product3_name", "product3_id", "15.15", 3);
ArrayList < Product > arrayList = new ArrayList < > (Arrays.asList(product1, product2, product3));
Bundle bundle = new Bundle();
bundle.putString(OmniAnalytics.PayloadType.EVENT_ACTION, OmniAnalytics.EventActionType.PURCHASE);
bundle.putFloat(OmniAnalytics.PayloadType.REVENUE, 20.20 f);
bundle.putSerializable(OmniAnalytics.DataType.PRODUCTS, arrayList);
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.EVENT, bundle);Bundle bundle = new Bundle();
bundle.putString(OmniAnalytics.PayloadType.EVENT_ACTION, OmniAnalytics.EventActionType.REFUND);
bundle.putString(OmniAnalytics.PayloadType.TRANSACTION_ID, "ABC");
bundle.putString(OmniAnalytics.PayloadType.PRODUCT_ACTION, "custom_product_action");
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.EVENT, bundle);Product product1 = new Product("product1_name", "product1_id", "10.10", 1);
product1.setBrand("Omni_Brand");
product1.setCategory("Omni_Category");
product1.setVariant("Omni_Variant");
product1.setCoupon("Omni_Coupon");
Product product2 = new Product("product2_name", "product2_id", "12.12", 2);
Product product3 = new Product("product3_name", "product3_id", "15.15", 3);
ArrayList < Product > arrayList = new ArrayList < > (Arrays.asList(product1, product2, product3));
Bundle bundle = new Bundle();
bundle.putString(OmniAnalytics.PayloadType.EVENT_ACTION, OmniAnalytics.EventActionType.REFUND);
bundle.putString(OmniAnalytics.PayloadType.TRANSACTION_ID, "ABC");
bundle.putString(OmniAnalytics.PayloadType.PRODUCT_ACTION, "custom_product_action");
bundle.putSerializable(OmniAnalytics.DataType.PRODUCTS, arrayList);
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.EVENT, bundle);Spinner spCheckout = findViewById(R.id.spCheckout);
final String[] checkoutArray = new String[] {
"Choose One", "ATM", "Credit Card"
};
ArrayAdapter < String > adapter = new ArrayAdapter < > (this, android.R.layout.simple_spinner_item, checkoutArray);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spCheckout.setAdapter(adapter);
spCheckout.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView < ? > parent, View view, int position, long id) {
Bundle bundle = new Bundle();
bundle.putString(OmniAnalytics.PayloadType.EVENT_ACTION, OmniAnalytics.EventActionType.CLICK_CHECKOUT);
bundle.putString(OmniAnalytics.PayloadType.PRODUCT_ACTION, "custom_product_action");
bundle.putInt(OmniAnalytics.PayloadType.CHECKOUT_STEP, position);
bundle.putString(OmniAnalytics.PayloadType.CHECKOUT_STEP_OPTION, checkoutArray[position]);
OmniAnalytics.getInstance(MainActivity.this).logEvent(OmniAnalytics.HitType.EVENT, bundle);
}
@Override
public void onNothingSelected(AdapterView < ? > parent) {
}
});