กำลังส่งวัตถุ Array ใน GTM

ฉันมีสามมิติและหนึ่งเมตริกใน Google Analytics ฉันกำลังเติมข้อมูลเหล่านี้ด้วยความช่วยเหลือของ Google Tag Manager ซึ่งฉันได้สร้างแท็กที่ดำเนินการในเหตุการณ์บางอย่าง

สิ่งนี้ทำงานได้ดีจนถึงเวลาที่ฉันจะส่งวัตถุชิ้นเดียว

(<any>window).dataLayer.push({
      AgentEmail: '[email protected]',
      AgentLocation: 'Delhi',
      AgentName: 'Agent0007',
      AgentCount: '100',
      event: 'agentInfo'
    });

แต่เมื่อฉันพยายามส่งออบเจ็กต์อาร์เรย์ ฉันก็ทำไม่ได้เหมือนกัน เช่น ถ้าสมมติว่าฉันต้องการส่งข้อมูลของเอเจนต์สองคน มันจะบันทึกข้อมูลเดียวเท่านั้น

  (<any>window).dataLayer.push({
      AgentEmail: '[email protected]',
      AgentLocation: 'Delhi',
      AgentName: 'Agent0007',
      AgentCount: '100',
      event: 'agentInfo'
    },({
       'AgentEmail': '[email protected]',
     'AgentLocation': 'Delhi',
     'AgentName': 'Agent0008',
      'AgentCount': '100',
     'event': 'agentInfo'
 });

แม้ว่าฉันจะพยายามสร้างออบเจ็กต์ชั้นข้อมูลสองออบเจ็กต์แยกจากกัน และพยายามส่งออบเจ็กต์ทั้งสองต่างกันออกไป แต่ก็ไม่ได้ผลเช่นกัน

โปรดช่วยเราหน่อยได้ไหมว่าต้องเปลี่ยนแปลงอะไรในแท็ก/ตัวแปร GTM และส่วนหน้าเพื่อเติมชั้นข้อมูล


person Bharat Joshi    schedule 21.05.2018    source แหล่งที่มา


คำตอบ (1)


คุณมีวงเล็บพิเศษ boi "(" ระหว่างวัตถุของคุณ

dataLayer.push({
      AgentEmail: '[email protected]',
      AgentLocation: 'Delhi',
      AgentName: 'Agent0007',
      AgentCount: '100',
      event: 'agentInfo'
    },{ //here you need to remove the "("
       'AgentEmail': '[email protected]',
     'AgentLocation': 'Delhi',
     'AgentName': 'Agent0008',
      'AgentCount': '100',
     'event': 'agentInfo'
 });
person Matus    schedule 22.05.2018
comment
สวัสดี ขออภัยที่ตอบกลับล่าช้าติดอยู่กับเรื่องอื่น ในขณะเดียวกัน แม้ว่าฉันจะทำตามที่คุณแนะนำ แต่ก็เป็นเพียงการพุชองค์ประกอบเดียวไปที่แท็ก GTM ขณะที่อยู่ในชั้นข้อมูล มันแสดงแนวคิดสองวัตถุว่าเราจะบรรลุเป้าหมายเดียวกันได้อย่างไร - person Bharat Joshi; 02.07.2018