我想为Android实施内部促销印象点击。我已经成功实施了内部促销印象。但是内部促销的点击不会反映在Google Analytics(分析)信息中心上。
这是我的跟踪展示次数点击的代码
public static void trackImpressionClick(Context context, ArrayList<String> promotionClickStrings){
Promotion promotion = new Promotion()
.setId(promotionClickStrings.get(0))
.setName(promotionClickStrings.get(1))
.setCreative(promotionClickStrings.get(2))
.setPosition(promotionClickStrings.get(3));
ProductAction promoClickAction = new ProductAction(Promotion.ACTION_CLICK);
HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder()
.addPromotion(promotion)
.setProductAction(promoClickAction)
.setCategory("Internal Promotions")
.setAction("click")
.setLabel(promotionClickStrings.get(1))
.setValue(0);
Tracker promotion_click_tracker = ((BaseApplication) context.getApplicationContext()).getTracker(
BaseApplication.TrackerName.APP_TRACKER);
promotion_click_tracker.send(builder.build());
}
在以下Google文档中:https : //developers.google.com/analytics/devguides/collection/android/v4/enhanced-ecommerce#measuring-promos
这是错误的,因为我们必须在Event Buider中使用setPromotionAction而不是setProductAction,这对我来说是成功的窍门。
public static void trackImpressionClick(Context context, ArrayList<String> promotionClickStrings) {
Log.d("NewSearchActivity", promotionClickStrings.get(0));
Promotion promotion = new Promotion()
.setId(promotionClickStrings.get(0))
.setName(promotionClickStrings.get(1))
.setCreative(promotionClickStrings.get(2))
.setPosition(promotionClickStrings.get(3));
ProductAction promoClickAction = new ProductAction(Promotion.ACTION_CLICK);
HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder()
.addPromotion(promotion)
.setPromotionAction(Promotion.ACTION_CLICK)
.setCategory("Internal Promotions")
.setAction("click")
.setLabel(promotionClickStrings.get(1));
Tracker promotion_click_tracker = ((BaseApplication) context.getApplicationContext()).getTracker(
BaseApplication.TrackerName.APP_TRACKER);
promotion_click_tracker.send(builder.build());
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句