0

I've configured a custom event on Google Tag Manager to send data about my product to Google Analytics using "datalayer", but when I send hit the event it's label is shown as [object Object] into analytics reports.

How do I get all properties of the product there?

Example of data that I'm pushing:

{
  'event': 'test',
  'action': 'add',
  'product': {
     'id': 32,
     'name': 'Product 1',
     'price': 99.99
  }
}

Example of how it's shown on Alanytics reports: enter image description here

Glenn Mateus
  • 319
  • 1
  • 2
  • 17

1 Answers1

1

You can as eventlabel not send an object in a label because label is type string. Lets make a test

var myProducts = {productid:1,productname:"name"}; //your object in datLayer
myProducts.toString(); //which probably analytics does

Output will be  [object Object]

Thats means to have to create a string from this object

you can make the object to string like '{productid:1,productname:"name"}' output in analytics will probably be {productid:1,productname:"name"}

you can change the form and write it as string "productid = 1, productname = name" //34 byte than it will displayed as productid = 1, productname = name

Max Length for Event Label = 500 Bytes https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#eventAction

you can check stackoverflow how to check the bytes in javascript from string String length in bytes in JavaScript

Recommended Annother thing google has enhanced ecommerce https://developers.google.com/tag-manager/enhanced-ecommerce