2

因此,我一直在尝试在带有 GTM 的 Android 应用上实现增强型 Ecom。它运行不佳,因为添加到购物车和购买事件不起作用。

我尝试在文档中复制粘贴推荐的调用,看看它是否有效。数据仍然没有以正确的方式出现。你知道可能是什么问题吗?

这是代码:

TagManager tagManager = TagManager.getInstance(this);
DataLayer dataLayer = tagManager.getDataLayer();

展示次数(在浏览量标签上触发,有效)

dataLayer.push("ecommerce",
 DataLayer.mapOf(
 "currencyCode", "EUR", // Local currency is optional.
 "impressions", DataLayer.listOf(
 DataLayer.mapOf(
 "name", "Triblend Android T-Shirt", // Name or ID is required.
 "id", "12345",
 "price", "15.25",
 "brand", "Google",
 "category", "Apparel",
 "variant", "Gray",
 "list", "Search Results",
 "position", 1),
 DataLayer.mapOf(
 "name", "Donut Friday Scented T-Shirt",
 "id", "67890",
 "price", "33.75",
 "brand", "Google",
 "category", "Apparel",
 "variant", "Black",
 "list", "Search Results",
 "position", 2))));

点击(事件触发,工作)

dataLayer.pushEvent("productClick",
 DataLayer.mapOf(
 "ecommerce", DataLayer.mapOf(
 "click", DataLayer.mapOf(
 "actionField", DataLayer.mapOf(
 "list", "Search Results"), // Optional list property.
 "products", DataLayer.listOf(
 DataLayer.mapOf(
 "name", "Triblend Android T-Shirt", // Name or ID is required.
 "id", "12345",
 "price", "15.25",
 "brand", "Google",
 "category", "Apparel",
 "variant", "Gray"))))));

详细信息(在浏览量标签上触发,工作)

dataLayer.push("ecommerce",
 DataLayer.mapOf(
 "detail", DataLayer.mapOf(
 "actionField", DataLayer.mapOf(
 "list", "Apparel Gallery"), // detail actions have an optional list property.
 "products", DataLayer.listOf(
 DataLayer.mapOf(
 "name", "Triblend Android T-Shirt", // Name or ID is required.
 "id", "12345",
 "price", "15.25",
 "brand", "Google",
 "category", "Apparel",
 "variant", "Gray")))));

添加到购物车(使用自定义事件触发,事件在 GA 中触发但没有数据进入。即使在标签上激活了数据层)

dataLayer.pushEvent("addToCart",
 DataLayer.mapOf(
 "ecommerce", DataLayer.mapOf(
 "currencyCode", "EUR",
 "add", DataLayer.mapOf( // 'add' actionFieldObject measures.
 "products", DataLayer.listOf(
 DataLayer.mapOf(
 "name", "Triblend Android T-Shirt",
 "id", "12345",
 "price", "15.25",
 "brand", "Google",
 "category", "Apparel",
 "variant", "Gray",
 "quantity", 1))))));

结帐(事件触发,工作)

dataLayer.pushEvent("checkout",
 DataLayer.mapOf(
 "ecommerce", DataLayer.mapOf(
 "checkout", DataLayer.mapOf(
 "actionField", DataLayer.mapOf(
 "step", 1,
 "option", "Visa"),
 "products", DataLayer.listOf(
 DataLayer.mapOf(
 "name", "Triblend Android T-Shirt",
 "id", "12345",
 "price", "15.25",
 "brand", "Google",
 "category", "Apparel",
 "variant", "Gray",
 "quantity", 1))))));

为了让购买生效,我们会在代码之后立即发送综合浏览量,以确保我们在之后发送点击以确保数据可以到达 GA。

dataLayer.push("ecommerce",
 DataLayer.mapOf(
 "purchase", DataLayer.mapOf(
 "actionField", DataLayer.mapOf(
 "id", "T12345", // Transaction ID. Required for purchases and refunds.
 "affiliation", "Online Store",
 "revenue", "35.43", // Total transaction value (incl. tax and shipping)
 "tax", "4.90",
 "shipping", "5.99",
 "coupon", "SUMMER_SALE"),
 "products", DataLayer.listOf( // List of productFieldObjects.
 DataLayer.mapOf(
 "name", "Triblend Android T-Shirt", // Name or ID is required.
 "id", "12345",
 "price", "15.25",
 "brand", "Google",
 "category", "Apparel",
 "variant", "Gray",
 "quantity", 1,
 "coupon", ""), // Optional fields may be omitted or set to empty string.
 DataLayer.mapOf(
 "name", "Donut Friday Scented T-Shirt",
 "id", "67890",
 "price", "33.75",
 "brand", "Google",
 "category", "Apparel",
 "variant", "Black",
 "quantity", 1))))); 

dataLayer.push(DataLayer.mapOf("event", "openScreen", "screenName", "TEST_SCREEN"));
  } 

知道为什么添加到购物车和购买无法使用此功能,即使结帐信息(之后发送)是?

谢谢,

4

0 回答 0