带有GTM的GA4-在不使用DataLayer的情况下将项目数组作为事件参数发送?
将GA4与GTM一起使用。我质疑如何发送活动阵列。例如,add_to_cart事件。在我的情况下,我正在触发购买链接上的标签。在这些链接上,我添加了ID,名称和值的数据参数,例如:
<a href="https://example.com/sales/link" data-id="prodid" data-name="prodname" data-value="179.95">Buy Now</a>
有多个和ID,名称和值是每个链接更改的唯一内容。
Google需要使用add_to_cart事件发送的项目数组。我可以使用点符号如下图中输入项目数组吗?我无法在DataLayer中提供此信息,这就是为什么我要抓住可能与链接本身不同的值(数据参数)...其余的是静态的并且不会更改。我找不到在GTM中创建数组变量的任何方法,因此点符号是我唯一能想到的。
有其他方法可以做到这一点吗?
Using GA4 with GTM. I'm questioning how to send an array for an event. For example, the add_to_cart event. In my situation I am triggering the tag on my purchase links. On those links I added data parameters for the id, name, and value such as :
<a href="https://example.com/sales/link" data-id="prodid" data-name="prodname" data-value="179.95">Buy Now</a>
There are multiple and the id, name, and value are the only things that change for each link.
Google requires an items array to be sent with the add_to_cart event. Can I enter the items array as shown in this picture using dot notation? I can't supply this information in the datalayer which is why I am grabbing the values that can be different from the link itself (data parameters)... the rest are static and won't change. I can't find any way to create an array variable in GTM so the dot notation is the only thing I could think of.
Is there another way to do this I am missing or not thinking of?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@Ramon把我朝着正确的方向。将其设置为自定义JS变量。由于我在链接上触发标签,单击
{{{单击元素}}
让我从中获取这些数据参数值以创建动态的数组值。我想我也可以使用我已经为这里创建的GTM变量。无论如何,我将此变量用作items
事件参数值,它返回了我希望的数组。似乎工作正常。@Ramon Put me in the right direction. Set this up as a custom js variable. Since I trigger the tag on link click the
{{Click Element}}
lets me get those data-parameter values from it to create the array values that are dynamic. I suppose I could have also used the gtm variables I already created for those here too. Anyways, I use this variable as theitems
event parameter value which returns the array how I wish. Seems to be working fine.不幸的是你不能。
您的解决方案将项目对象的每个值作为单个事件参数发送。
GA4要求您发送一系列对象,每个物品都有一个对象。
好消息是,您可以使用GTM使用一些JavaScript以正确的格式创建项目数组。
Unfortunately you can't.
Your solution sends every value from the items object as an individual event parameter.
GA4 requires you to send an array of objects, with one object for every sold item.
The good news is, you can use GTM to create the items array in the correct format using some JavaScript.