Google通用分析:在一次展示事件中推送多个子事件(电子商务)(Google Universal Analytics: push several sub

编程入门 行业动态 更新时间:2024-10-26 14:33:53
Google通用分析:在一次展示事件中推送多个子事件(电子商务)(Google Universal Analytics: push several sub-events in one impressions event (E-commerce))

我正在尝试使用Universal Analytics在电子商务目录页面上实施产品展示( https://developers.google.com/tag-manager/enhanced-ecommerce#product-impressions )。 我遇到的问题具有实用性,我希望推送一个包含每个展示对象的事件,而不是每个目录产品的事件,但事实并非如此:

显示在目录列表中的每个产品最终都会在dataLayer中成为一个展示对象,而不是拥有一个包含所有信息的展示对象(例如Google自己的示例)。 有没有办法将每个productImpressions事件嵌套到一个,然后推送包含所有目录页结果的那个对象? 这是我目前实现的代码,它推送到dataLayer:

// Product View, triggered when product is viewed on any page: function googleTagManagerProductViewDataLayerPush(productName, productSKU, productPrice, productBrand, productCategory, productVariant, productList, positionInList, regularProductPrice) { dataLayer.push({ 'event': 'productImpressions', 'ecommerce': { 'currencyCode': 'SEK', 'impressions': [{ 'name': productName, 'id': productSKU, 'price': productPrice, 'brand': productBrand, 'category': productCategory, 'variant': productVariant, 'list': productList, 'position': positionInList, 'metric1': regularProductPrice }, { 'name': productName, 'id': productSKU, 'price': productPrice, 'brand': productBrand, 'category': productCategory, 'variant': productVariant, 'list': productList, 'position': positionInList, 'metric1': regularProductPrice }] } }); }

我为产品目录中的每个产品/项目调用此函数,例如搜索结果。 我想我可以发送数组,但这不会动态创建嵌套在一个productImpressions事件中的每个产品的对象,我想要。

有没有人有关于如何解决这个问题的想法?

I'm trying to implement product impressions (https://developers.google.com/tag-manager/enhanced-ecommerce#product-impressions) on an ecommerce catalog page using Universal Analytics. The problem i'm having is of practical nature, where I want to push one event containing every impression-object rather than an event for each catalogue product being displayed, but that is not the case as can be seen here:

Each product being displayed in the catalogue list ends up becoming an impressions-object by itself in the dataLayer, rather than having one impressions-object with all the information (such as Google's own example). Is there a way of nesting each productImpressions event into one, and then pushing that one object containing all catalogue-page results? This is the code I have implemented at the moment which does the pushing to the dataLayer:

// Product View, triggered when product is viewed on any page: function googleTagManagerProductViewDataLayerPush(productName, productSKU, productPrice, productBrand, productCategory, productVariant, productList, positionInList, regularProductPrice) { dataLayer.push({ 'event': 'productImpressions', 'ecommerce': { 'currencyCode': 'SEK', 'impressions': [{ 'name': productName, 'id': productSKU, 'price': productPrice, 'brand': productBrand, 'category': productCategory, 'variant': productVariant, 'list': productList, 'position': positionInList, 'metric1': regularProductPrice }, { 'name': productName, 'id': productSKU, 'price': productPrice, 'brand': productBrand, 'category': productCategory, 'variant': productVariant, 'list': productList, 'position': positionInList, 'metric1': regularProductPrice }] } }); }

I call this function for each product/item on my product catalogue, for instance search results. I'm thinking I could send in arrays but that wouldn't dynamically create objects of each product being displayed nested within one productImpressions event, which I would like.

Does anyone have ideas on how to solve this?

最满意答案

不确定为什么要为每个产品调用dataLayer。 您需要首先创建所有产品的数组,然后使用所有产品调用dataLayer.push。 此外,我建议限制您一次推送的产品数量,可能是10或20,否则请求可能会变得太大而且可能无法发送。

您似乎也在推动同一产品两次。

Not sure why you are calling the dataLayer push for every single product. You need to first create an array of all the products and then call dataLayer.push with all of them. Also I'd recommend limiting the number of products you push at once, to maybe 10 or 20 because otherwise the request can get too big and might not be sent.

It also seems like you are pushing the same product twice.

更多推荐

本文发布于:2023-04-29 12:12:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336268.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   事件   电子商务   事件中   Google

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!