このドキュメントでは、Android 向け Google アナリティクス SDK v4 を使って、アプリ内 e コマース関連のアクションとインプレッションを測定する方法の概要を説明します。
概要
拡張 e コマースを使用すると、ショッピング ユーザーと商品との
インタラクション(商品のインプレッション、商品のクリック、商品情報
の表示、ショッピング カートへの商品の追加、決済プロセスの開始、
トランザクション、払い戻しなど)を測定できます。
実装
拡張 e コマース測定では、HitBuilder
クラスとその一連のメソッドを使って、商品、インプレッション、プロモーションの e コマースデータを送信する必要があります。e コマース関連の情報を構築するために、一連の Google アナリティクス e コマースクラス も用意されています。
拡張 e コマースでは次のことが可能です。
e コマース アクティビティの測定
拡張 e コマースの標準的な実装では、商品のインプレッションに加え、次のようなアクションが測定されます。
商品のクリック
商品情報の表示
社内プロモーションのインプレッションとクリック
ショッピング カートへの商品の追加や削除
商品の決済プロセスの開始
購入と払い戻し
注 : 拡張 e コマースデータは、既存のヒット(screenview
、event
など)に付加されている場合にのみ送信できます。e コマースの値を設定してもヒットを送信しなかった場合、または e コマースの値の設定前にヒットが送信された場合、e コマースデータは送信されません。
インプレッションの測定
商品のインプレッションを測定するには、Product
オブジェクトを作成し、addImpression
メソッドを使用してヒットとともに送信します。Product
には名前または ID の値を設定する必要があります。その他の値はすべてオプションで、設定しなくてもかまいません。
Product product = new Product()
.setId("P12345")
.setName("Android Warhol T-Shirt")
.setCategory("Apparel/T-Shirts")
.setBrand("Google")
.setVariant("Black")
.setPosition(1)
.setCustomDimension(1, "Member");
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addImpression(product, "Search Results");
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("searchResults");
t.send(builder.build());
getTracker
メソッドの詳細については、
高度な構成 をご覧ください。
アクションの測定
アクションを測定するには、Product
オブジェクトを伴う addProduct
メソッドで商品情報を追加し、ProductAction
オブジェクトを伴う setProductAction
メソッドで実施するアクションを指定します。
次のサンプルコードは、検索結果のリストに表示された商品の
クリックを測定するものです。
Product product = new Product()
.setId("P12345")
.setName("Android Warhol T-Shirt")
.setCategory("Apparel/T-Shirts")
.setBrand("Google")
.setVariant("Black")
.setPosition(1)
.setCustomDimension(1, "Member");
ProductAction productAction = new ProductAction(ProductAction.ACTION_CLICK)
.setProductActionList("Search Results");
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addProduct(product)
.setProductAction(productAction);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("searchResults");
t.send(builder.build());
インプレッションとアクションの併合
商品のインプレッションとアクションの両方が発生する場面では、1 回のヒットで 2 つをまとめて測定することが可能です。
次のサンプルコードは、商品情報を表示したアクションに、関連する商品セクションの情報を付けて測定する方法を示したものです。
// The product from a related products section.
Product relatedProduct = new Product()
.setId("P12346")
.setName("Android Warhol T-Shirt")
.setCategory("Apparel/T-Shirts")
.setBrand("Google")
.setVariant("White")
.setPosition(1);
// The product being viewed.
Product viewedProduct = new Product()
.setId("P12345")
.setName("Android Warhol T-Shirt")
.setCategory("Apparel/T-Shirts")
.setBrand("Google")
.setVariant("Black")
.setPosition(1);
ProductAction productAction = new ProductAction(ProductAction.ACTION_DETAIL);
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addImpression(relatedProduct, "Related Products")
.addProduct(viewedProduct)
.setProductAction(productAction);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("product");
t.send(builder.build());
トランザクションの測定
トランザクションを測定するには、addProduct
メソッド(Product
オブジェクト付き)で商品の詳細を追加し、setProductAction
メソッド(ProductAction
オブジェクト付き)で購入アクションを指定します。合計収益額、税金、送料といったトランザクション単位の情報は ProductAction
オブジェクトで提供されます。
Product product = new Product()
.setId("P12345")
.setName("Android Warhol T-Shirt")
.setCategory("Apparel/T-Shirts")
.setBrand("Google")
.setVariant("black")
.setPrice(29.20)
.setCouponCode("APPARELSALE")
.setQuantity(1);
ProductAction productAction = new ProductAction(ProductAction.ACTION_PURCHASE)
.setTransactionId("T12345")
.setTransactionAffiliation("Google Store - Online")
.setTransactionRevenue(37.39)
.setTransactionTax(2.85)
.setTransactionShipping(5.34)
.setTransactionCouponCode("SUMMER2013");
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addProduct(product)
.setProductAction(productAction);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("transaction");
t.send(builder.build());
通貨の指定
デフォルトでは、Google アナリティクスの管理画面を介してすべてのトランザクションと商品で使用するグローバル通貨を設定できます。
ローカル通貨は ISO 4217
規格で指定します。サポートされている通貨の全一覧については、通貨コードのリファレンス をご覧ください。
ローカル通貨は currencyCode トラッカー プロパティを使って指定します。次のサンプルコードでは、通貨の値としてユーロが送られます。
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("transaction");
t.set("&cu", "EUR"); // Set tracker currency to Euros.
t.send(builder.build());
Google アナリティクスでの通貨換算の仕組みについては、e コマースの機能のリファレンスで複数の通貨 のセクションをご覧ください。
払い戻しの測定
1 件のトランザクションすべての払い戻しを行うには、ProductAction
オブジェクトを指定して setProductAction
メソッドを使用して、払い戻しの対象となるトランザクション ID と払い戻しアクション タイプを指定します。
// Refund an entire transaction.
ProductAction productAction = new ProductAction(ProductAction.ACTION_REFUND)
.setTransactionId("T12345"); // Transaction ID is only required field for a full refund.
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.setProductAction(productAction);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("refund");
t.send(builder.build());
該当するトランザクションがない場合、払い戻しは処理されません。
一部払い戻しを測定するには、ProductAction
オブジェクトを伴う setProductAction
メソッドを使用して、払い戻しの対象となるトランザクション ID、商品 ID、商品数を指定します。
// Refund a single product.
Product product = new Product()
.setId("P12345") // Product ID is required for partial refund.
.setQuantity(1); // Quanity is required for partial refund.
ProductAction productAction = new ProductAction(ProductAction.ACTION_REFUND)
.setTransactionId("T12345"); // Transaction ID is required for partial refund.
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addProduct(product)
.setProductAction(productAction);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("refundProduct");
t.send(builder.build());
払い戻しで非インタラクション イベントを使用する場合
払い戻しデータをイベントを使って送る必要があり、標準的に測定するユーザー行動にそのイベントが含まれない(ユーザーが行うイベントではない)場合は、非インタラクション イベントを使って送ることをおすすめします。これにより、指標にイベントの影響を与えずに済みます。次に例を示します。
// Refund an entire transaction.
ProductAction productAction = new ProductAction(ProductAction.ACTION_REFUND)
.setTransactionId("T12345");
HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder()
.setProductAction(productAction)
.setNonInteraction(true)
.setCategory("Ecommerce")
.setAction("Refund");
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.send(builder.build());
決済プロセスの測定
決済プロセスの各ステップを測定する手順は次のとおりです。
決済プロセスの各ステップを測定するトラッキング コードを追加します。
必要に応じて、決済オプションを測定するトラッキング コードを追加します。
オプションとして、管理画面の [アナリティクス設定] の [e コマースの設定 ] で、決済目標到達プロセスのレポートに表示するわかりやすいステップ名を設定します。
1. 決済ステップの測定
決済プロセスの各ステップを測定するには、そのためのトラッキング コードを各ステップに実装し、Google アナリティクスにデータを送る必要があります。
Step
フィールド
測定の対象とする決済ステップには、必ず step
値を含めます。この値は、[e コマースの設定 ] で指定した各ステップのラベル(名前)と決済アクションを結び付けるために使われます。
注 : 決済プロセスが 1 ステップの場合や、[e コマースの設定 ] で決済目標到達プロセスを設定していない場合、step
フィールドは省略できます。
Option
フィールド
決済ステップの測定時にステップに関する情報を追加する場合は、checkout
アクションで option
フィールドにその情報を設定します。たとえば、対象ユーザーのデフォルトのお支払い方法(例: 「Visa」)などを設定します。
個々の決済ステップの測定
個々の決済ステップを測定するには、addProduct
メソッド(Product
オブジェクト)で商品情報を追加し、setProductAction
メソッド(ProductAction
オブジェクト)で決済アクションであることを示します。必要に応じて、購入手続きに step
と option
を設定することもできます。
次のサンプルコードは、決済プロセスの最初のステップの測定方法を示したもので、1 個の商品と、お支払い方法に関する追加情報が付加されています。
Product product = new Product()
.setId("P12345")
.setName("Android Warhol T-Shirt")
.setCategory("Apparel/T-Shirts")
.setBrand("Google")
.setVariant("black")
.setPrice(29.20)
.setQuantity(1);
// Add the step number and additional info about the checkout to the action.
ProductAction productAction = new ProductAction(ProductAction.ACTION_CHECKOUT)
.setCheckoutStep(1)
.setCheckoutOptions("Visa");
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addProduct(product)
.setProductAction(productAction);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("checkoutStep1");
t.send(builder.build());
2. 決済オプションの測定
決済オプションを使用すると、決済に関する追加情報を測定できます。この機能は、1 つの決済ステップを測定した後で同じ決済ステップの別のオプションが指定され、追加情報が出た場合に便利です。たとえば、ユーザーが選択した配送方法を情報として追加できます。
決済オプションを測定するには、setAction
を使って決済オプションであることを示し、ステップ番号とオプションの説明を含めます。
注 : 商品データやインプレッション データは設定しないでください。
このアクションは、ユーザーが決済プロセスの次のステップに移るアクションを実施した後に測定することをおすすめします。次に例を示します。
// (On "Next" button click.)
ProductAction productAction = new ProductAction(ProductAction.ACTION_CHECKOUT_OPTIONS)
.setCheckoutStep(1)
.setCheckoutOptions("FedEx");
HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder()
.setProductAction(productAction)
.setCategory("Checkout")
.setAction("Option");
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.send(builder.build());
// Advance to next page.
3. 決済目標到達プロセスの設定
決済プロセスのステップごとに、レポートで使用するわかりやすい名前を設定できます。こうした名前を設定するには、Google アナリティクスの管理画面の [アナリティクス設定 ] で対象のビュー(旧プロファイル)を選択して [e コマースの設定 ] をクリックします。表示される e コマースの設定手順に従って、測定する個々の決済ステップに名前を設定します。
注 : 決済ステップの名前を設定しない場合は、ステップ 1、2、3 のように表示されます。
図 1 : e コマースの設定 - 決済目標到達プロセス
拡張 e コマースでは、社内プロモーション(セールを宣伝するバナー広告など)のインプレッションとクリックの測定をサポートしています。
内部プロモーションのインプレッションは通常、Promotion
オブジェクトで addPromotion
メソッドを使用し、プロモーションの詳細を指定して、最初のスクリーン ビューで測定します。次に例を示します。
Promotion promotion = new Promotion()
.setId("PROMO_1234")
.setName("Summer Sale")
.setCreative("summer_banner2")
.setPosition("banner_slot1");
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addPromotion(promotion);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("promotions");
t.send(builder.build());
重要 : プロモーションのインプレッションにはアクションを設定できますが、プロモーション アクション クリックは指定できません。プロモーションのクリック アクションを測定するには、プロモーションのインプレッションが発生した後に、別のヒットで測定する必要があります。
社内プロモーションのクリックを測定するには、Promotion
オブジェクトを指定して addPromotion
メソッドを使用し、setPromotionAction
メソッドを Promotion.ACTION_CLICK
または Promotion.ACTION_VIEW
に設定して、プロモーションのクリックまたはビューをそれぞれ示します。次に例を示します。
Promotion promotion = new Promotion()
.setId("PROMO_1234")
.setName("Summer Sale")
.setCreative("summer_banner2")
.setPosition("banner_slot1");
HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder()
.addPromotion(promotion)
.setPromotionAction(Promotion.ACTION_CLICK)
.setCategory("Internal Promotions")
.setAction("click")
.setLabel("Summer Sale");
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.send(builder.build());
サンプル アプリケーションのサンプルコード
次のコード スニペットは、拡張 e コマースの全機能を網羅したサンプルです。
package com.google.android.apps.mobileplayground;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.google.android.apps.mobileplayground.AnalyticsSampleApp.TrackerName;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import com.google.android.gms.analytics.ecommerce.Product;
import com.google.android.gms.analytics.ecommerce.ProductAction;
import com.google.android.gms.analytics.ecommerce.Promotion;
/**
* Class to exercise Enhanced Ecommerce hits.
*/
public class EnhancedEcommerceFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = inflater.inflate(R.layout.enhanced_ecommerce, container, false);
Button button = (Button) view.findViewById(R.id.enhancedEcommerceImpression);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
measureImpression();
}
});
button = (Button) view.findViewById(R.id.enhancedEcommerceAction);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
measureAction();
}
});
button = (Button) view.findViewById(R.id.enhancedEcommerceImpressionAndAction);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
measureImpressionAndAction();
}
});
button = (Button) view.findViewById(R.id.enhancedEcommerceTransaction);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
measureTransaction();
}
});
button = (Button) view.findViewById(R.id.enhancedEcommerceRefundTransaction);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
measureRefundTransaction();
}
});
button = (Button) view.findViewById(R.id.enhancedEcommerceRefundProduct);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
measureRefundProduct();
}
});
button = (Button) view.findViewById(R.id.enhancedEcommerceRefundNonInteraction);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
measureRefundNonInteraction();
}
});
button = (Button) view.findViewById(R.id.enhancedEcommerceCheckoutStep);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
measureCheckoutStep();
}
});
button = (Button) view.findViewById(R.id.enhancedEcommerceCheckoutOption);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
measureCheckoutOption();
}
});
button = (Button) view.findViewById(R.id.enhancedEcommercePromotionImpression);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
measurePromotionImpression();
}
});
button = (Button) view.findViewById(R.id.enhancedEcommercePromotionClick);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
measurePromotionClick();
}
});
return view;
}
private void measureImpression() {
Product product = new Product()
.setId("P12345")
.setName("Android Warhol T-Shirt")
.setCategory("Apparel/T-Shirts")
.setBrand("Google")
.setVariant("Black")
.setPosition(1)
.setCustomDimension(1, "Member");
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addImpression(product, "Search Results");
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("searchResults");
t.send(builder.build());
}
private void measureAction() {
Product product = new Product()
.setId("P12345")
.setName("Android Warhol T-Shirt")
.setCategory("Apparel/T-Shirts")
.setBrand("Google")
.setVariant("Black")
.setPosition(1)
.setCustomDimension(1, "Member");
ProductAction productAction = new ProductAction(ProductAction.ACTION_CLICK)
.setProductActionList("Search Results");
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addProduct(product)
.setProductAction(productAction);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("searchResults");
t.send(builder.build());
}
private void measureImpressionAndAction() {
// The product from a related products section.
Product relatedProduct = new Product()
.setId("P12346")
.setName("Android Warhol T-Shirt")
.setCategory("Apparel/T-Shirts")
.setBrand("Google")
.setVariant("White")
.setPosition(1);
// The product being viewed.
Product viewedProduct = new Product()
.setId("P12345")
.setName("Android Warhol T-Shirt")
.setCategory("Apparel/T-Shirts")
.setBrand("Google")
.setVariant("Black")
.setPosition(1);
ProductAction productAction = new ProductAction(ProductAction.ACTION_DETAIL);
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addImpression(relatedProduct, "Related Products")
.addProduct(viewedProduct)
.setProductAction(productAction);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("product");
t.send(builder.build());
}
private void measureTransaction() {
Product product = new Product()
.setId("P12345")
.setName("Android Warhol T-Shirt")
.setCategory("Apparel/T-Shirts")
.setBrand("Google")
.setVariant("black")
.setPrice(29.20)
.setCouponCode("APPARELSALE")
.setQuantity(1);
ProductAction productAction = new ProductAction(ProductAction.ACTION_PURCHASE)
.setTransactionId("T12345")
.setTransactionAffiliation("Google Store - Online")
.setTransactionRevenue(37.39)
.setTransactionTax(2.85)
.setTransactionShipping(5.34)
.setTransactionCouponCode("SUMMER2013");
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addProduct(product)
.setProductAction(productAction);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("transaction");
t.send(builder.build());
}
private void measureRefundTransaction() {
// Refund an entire transaction.
ProductAction productAction = new ProductAction(ProductAction.ACTION_REFUND)
.setTransactionId("T12345"); // Transaction ID is only required field for a full refund.
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.setProductAction(productAction);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("refund");
t.send(builder.build());
}
private void measureRefundProduct() {
// Refund a single product.
Product product = new Product()
.setId("P12345") // Product ID is required for partial refund.
.setQuantity(1); // Quanity is required for partial refund.
ProductAction productAction = new ProductAction(ProductAction.ACTION_REFUND)
.setTransactionId("T12345"); // Transaction ID is required for partial refund.
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addProduct(product)
.setProductAction(productAction);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("refundProduct");
t.send(builder.build());
}
private void measureRefundNonInteraction() {
// Refund an entire transaction.
ProductAction productAction = new ProductAction(ProductAction.ACTION_REFUND)
.setTransactionId("T12345");
HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder()
.setProductAction(productAction)
.setNonInteraction(true)
.setCategory("Ecommerce")
.setAction("Refund");
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.send(builder.build());
}
private void measureCheckoutStep() {
Product product = new Product()
.setId("P12345")
.setName("Android Warhol T-Shirt")
.setCategory("Apparel/T-Shirts")
.setBrand("Google")
.setVariant("black")
.setPrice(29.20)
.setQuantity(1);
// Add the step number and additional info about the checkout to the action.
ProductAction productAction = new ProductAction(ProductAction.ACTION_CHECKOUT)
.setCheckoutStep(1)
.setCheckoutOptions("Visa");
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addProduct(product)
.setProductAction(productAction);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("checkoutStep1");
t.send(builder.build());
}
private void measureCheckoutOption() {
// (On "Next" button click.)
ProductAction productAction = new ProductAction(ProductAction.ACTION_CHECKOUT_OPTIONS)
.setCheckoutStep(1)
.setCheckoutOptions("FedEx");
HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder()
.setProductAction(productAction)
.setCategory("Checkout")
.setAction("Option");
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.send(builder.build());
// Advance to next page.
}
private void measurePromotionImpression() {
Promotion promotion = new Promotion()
.setId("PROMO_1234")
.setName("Summer Sale")
.setCreative("summer_banner2")
.setPosition("banner_slot1");
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.addPromotion(promotion);
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("promotions");
t.send(builder.build());
}
private void measurePromotionClick() {
Promotion promotion = new Promotion()
.setId("PROMO_1234")
.setName("Summer Sale")
.setCreative("summer_banner2")
.setPosition("banner_slot1");
HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder()
.addPromotion(promotion)
.setPromotionAction(Promotion.ACTION_CLICK)
.setCategory("Internal Promotions")
.setAction("click")
.setLabel("Summer Sale");
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.send(builder.build());
}
}