简体   繁体   中英

How to track ecommerce events with Google Tag Manager v5 to Google Analytics?

We currently update the Tag Manager from v4 to v5 in our Android application. The problem we see, is that the Enhanced ecommerce events are now only visible in Firebase Analytics, but not in Google Analytics.

With the usage of v4 we have tracked an transaction in the following way ( https://developers.google.com/tag-manager/android/v4/enhanced-ecommerce ):

// Send transaction data with a screenview if possible.
// Otherwise, use an event when the transaction data becomes available.
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)))));

Now we use the v5 way of tracking an transaction in this way ( https://developers.google.com/tag-manager/android/v5/enhanced-ecommerce ):

// Define product with relevant parameters

Bundle product1 = new Bundle();
product1.putString( Param.ITEM_ID, "sku1234"); // ITEM_ID or ITEM_NAME is required
product1.putString( Param.ITEM_NAME, "Donut Friday Scented T-Shirt");
product1.putString( Param.ITEM_CATEGORY, "Apparel/Men/Shirts");
product1.putString( Param.ITEM_VARIANT, "Blue");
product1.putString( Param.ITEM_BRAND, "Google");
product1.putDouble( Param.PRICE, 29.99 );
product1.putString( Param.CURRENCY, "USD" ); // Item-level currency unused today
product1.putLong( Param.QUANTITY, 1 );

Bundle product2 = new Bundle();
product2.putString( Param.ITEM_ID, "sku5678");
product2.putString( Param.ITEM_NAME, "Android Workout Capris");
product2.putString( Param.ITEM_CATEGORY, "Apparel/Women/Pants");
product2.putString( Param.ITEM_VARIANT, "Black");
product2.putString( Param.ITEM_BRAND, "Google");
product2.putDouble( Param.PRICE, 39.99 );
product2.putString( Param.CURRENCY, "USD" ); // Item-level currency unused today
product2.putLong( Param.QUANTITY, 1 );

// Prepare ecommerce bundle

ArrayList items = new ArrayList();
items.add(product1);
items.add(product2);

Bundle ecommerceBundle = new Bundle();
ecommerceBundle.putParcelableArrayList( "items", items );

// Set relevant transaction-level parameters

ecommerceBundle.putString( Param.TRANSACTION_ID, "T12345" );
ecommerceBundle.putString( Param.AFFILIATION, "Google Store - Online" );
ecommerceBundle.putDouble( Param.VALUE, 37.39 );        // Revenue
ecommerceBundle.putDouble( Param.TAX, 2.85 );
ecommerceBundle.putDouble( Param.SHIPPING, 5.34 );
ecommerceBundle.putString( Param.CURRENCY, "USD" );
ecommerceBundle.putString( Param.COUPON, "SUMMER2017" );

// Log ecommerce_purchase event with ecommerce bundle

mFirebaseAnalytics.logEvent( Event.ECOMMERCE_PURCHASE, ecommerceBundle );

Our setup for the Event.ECOMMERCE_PURCHASE event looks this way.

Our goal is it to continue be able to see transactions in Google Analytics here:

But it is not appearing there. The ecommerce event is appearing fine in Firebase Analytics. Also other events are sent successfully to Google Analytics, expect this ecommerce event.

Any ideas on how to continue tracking this Google Analytics Transaction Events? Resources of a working example of our problem would be also already helpful. So basically I'm looking for an updated documentation of https://support.google.com/tagmanager/answer/6107169?hl=en . Thanks for any help!

Your using a google analytics universal event and asking it to use fire base event to send e-commerce data, try change this to variable and use the variable you have wrote?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM