我一直在嘗試實施增強型電子商務跟蹤,但無論我做什麼,Google Analytcs中的電子商務視圖都保持爲空,即沒有數據發送(顯然)。所有其他數據,屏幕和事件跟蹤按預期工作。Google Analytics(分析)針對Android問題的增強型電子商務跟蹤
我遵循有關installing google analytics和implementing Enhanced Ecommerce tracking的官方指南。這裏是我的設置:
在所有MyApplication類:
public class MyApplication extends Application {
private Tracker mTracker;
//....
synchronized public Tracker getDefaultTracker() {
if (mTracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
mTracker = analytics.newTracker(R.xml.global_tracker);
mTracker.set("&tid", GOOGLE_ANALYTICS_ID_VALUE);
}
return mTracker;
}
}
的R.xml.global_tracker:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="ga_sessionTimeout">300</integer>
<bool name="ga_autoActivityTracking">false</bool>
<string name="ga_sampleFrequency">100.0</string>
<bool name="ga_reportUncaughtExceptions">true</bool>
<integer name="ga_dispatchPeriod">30</integer>
</resources>
在BaseActivity類我有我在適當的活動使用trackEcommerce()方法/片段:
public void trackEcommerce(){
String screenName = "eCommerce";
String transactionID = "transactionID"; //some randomized value
Double transactionRevenue = 0.0; //value of the transaction
Tracker t = ((MyApplication) getApplication()).getDefaultTracker();
//send products
for (MyEcommerceItem item : myEcommerceItems) {
Product product = new Product()
.setId(item.getSku())
.setName(item.getTitle())
.setCategory(item.getType())
.setPrice(item.getPrice())
.setQuantity(item.getQuantity());
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder().addProduct(product);
t.setScreenName(screenName);
t.send(builder.build());
}
//send transaction
ProductAction productAction = new ProductAction(ProductAction.ACTION_CHECKOUT)
.setTransactionId(transactionID)
.setTransactionRevenue(transactionRevenue);
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder().setProductAction(productAction);
t.setScreenName(screenName);
t.send(builder.build());
}
明顯的問題,你能看到我是doi的東西錯誤/我需要改變的一些想法?