You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Google Tag Manager中为Google Ads配置多个Product ID的正确语法是什么?

Troubleshooting the Product ID Array Error in GTM for Google Ads

Hey there! Let’s break down why you’re hitting that "Product IDs need to be an array" error even when you think you’ve set up an array. I’ve dealt with this exact headache a few times, so here are the most common culprits to check:

  • You’re using a string instead of an actual JavaScript array
    This is the #1 mistake. If you’ve typed something like "['prod123', 'prod456']" (with quotes wrapping the whole thing) in a GTM constant variable, that’s a string, not an array. Google Ads requires a real JS array object. Fix this by switching to a Custom JavaScript variable and returning the array directly:

    return ['prod123', 'prod456', 'prod789'];
    
  • Wrong variable type in GTM
    If you’re using a "Constant" variable to store your Product IDs, GTM treats anything you input as a string—even if it looks like an array. Always use a Custom JavaScript variable for arrays, because it lets you return actual JavaScript data types instead of plain text.

  • Mismatched nested format (for product objects)
    If you’re sending product data as part of an items array (like for Enhanced Conversions or Shopping Campaign tracking), double-check the structure. You might have accidentally nested a string instead of an array of product objects. For example:
    ❌ Wrong:

    return {
      items: "['prod001', 'prod002']"
    };
    

    ✅ Correct:

    return {
      items: [
        { id: 'prod001' },
        { id: 'prod002' }
      ]
    };
    

    Google Ads expects each entry in items to be an object with an id field, not just a raw array of strings (depending on the specific tracking implementation you’re using).

  • Quick way to verify
    Fire up GTM’s Preview mode, trigger your product page view, and inspect your variable. Look at the "Type" field for the variable—if it says String instead of Array, that’s your problem right there.

内容的提问来源于stack exchange,提问作者Rob

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 13:29:12