"[object Object]" displayed for items array within Analytics 4 debug
Asked Answered
S

1

6

I'm migrating a website that currently uses UA analytics configured via GTM to use Analytics 4.

Currently, the Website has the following purchase push event:

({'event':'purchase','ecommerce':{
    'purchase'{
        'currency':'GBP',
        'value':'24.99',
        'tax':'6.3300',
        'shipping':'6.6600',
        'coupon':'',
        'transaction_id':'450048423',
        'total_qty':'1',
        'items':[{
             'name':'Lasher Tools Deluxe Lopping Bypass Shears',
             'id':'119836',
             'price':'24.99',
             'quantity':'1.0000'
        }]
     }
   }
);

I've created a new tag for the Analytics 4 conversion which uses variables populated from the dataLayer of this push. This works fine for everything aside from the items array which returns as [object Object] when debugging via Google Analytics:

Image for Analytics debug

Here's how the items array looks when I view via the Tag Manager debug:

Tag Manager Debug

I can see the 'purchase' event within Analytics, however if I view the 'ecommerce' tabs then the revenue shows as £0.00 and the items columns are all empty which I can only assume is because of the items array issue?

Siegfried answered 19/5, 2022 at 14:53 Comment(2)
I have the same exact issue. Did you ever figure it out?Colwin
I had a similar issue where the array was being passed as [object Object] and then being saved as a string in in BigQuery. My solution was to create a 'Custom Javascript' variable that took in the array and then dot indexed into the key that I wanted. I then added this to the tag. function(){ var e = {{array}}; var items = e.key; return items; }Evergreen
D
0

Why are you passing qty,value,price and other non string params as string?

Please take a look into official documentation:

https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag#purchase

You can even toggle example for either GTag or GTM (at the top of the page)

Also please take a look, it seems the way you are invoking the event is a bit different then in official doc.

Take also look what params are required and which are not :)

Drain answered 29/11, 2023 at 20:52 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.