简体   繁体   English

Google跟踪代码管理器和Magento商店

[英]Google Tag Manager and Magento shop

I try to connect Google Tag Manager with Magento. 我尝试将Google跟踪代码管理器与Magento连接起来。 On google site I find a couple of Data Layer Variable Names . 在谷歌网站上,我找到了几个Data Layer Variable Names

<script>
  dataLayer = [{
    'pageCategory': 'signup',
    'visitorType': 'high-value'
  }];
</script>

Is there any site or place where can I find the name of magento Data Layer eg 是否有任何网站或地方可以找到magento数据层的名称,例如

  • id ID
  • name 名称
  • sku SKU
  • category 类别
  • price 价钱
  • quantity 数量

Thanks for any advice. 谢谢你的建议。

GTM can use predefined macro names for the eCommerce transaction, like this: GTM可以为电子商务交易使用预定义的宏名称,如下所示:

<script> 
dataLayer = [{ 
  'transactionId': '1234', 
  'transactionDate': '13112012', 
  'transactionType': 'Type 1', 
  'transactionAffiliation': 'ACME Clothing', 
  'transactionTotal': 25.60, 
  'transactionShipping': 5.00, 
  'transactionTax': 1.00, 
  'transactionPaymentType': 'Paypal', 
  'transactionCurrency': 'EUR', 
  'transactionShippingMethod': 'Store pickup', 
  'transactionPromoCode': '', 
  'transactionProducts': [{ 
    'id': '12', 
    'name': 'Red leather boots', 
    'sku': '45622LTHRBOOTS', 
    'category': 'Shoes > Boots', 
    'price': 450.00, 
    'quantity': 2 
    }, 
    { 
    'id': '14', 
    'name': 'Black leather jacket', 
    'sku': '456VESRTE', 
    'category': 'Clothing > Jackets', 
    'price': 750.00, 
    'quantity': 1 
    }] 
}]; 
</script>

As far as I understand it, in Google Tag Manager you work within a container, targeting one or all of your sites. 据我所知,在Google跟踪代码管理器中,您可以在一个容器中工作,定位您的一个或所有网站。 Each container has its own datalayer (can be named however you like). 每个容器都有自己的数据层(可以根据需要命名)。 In this datalayer you push variables and events, all of which are completely user-defined. 在这个数据层中,您可以推送变量和事件,所有这些都是完全由用户定义的。 This means there is no real "magento data layer", just THE datalayer, which contains the variables YOU have defined. 这意味着没有真正的“magento数据层”,只有数据层,它包含您定义的变量。

If your magento tag needs an sku value, you should define it in the datalayer yourself, ex.: 如果您的magento标签需要sku值,您应该自己在数据层中定义它,例如:

<script>
  dataLayer = [{
    'idSku': '102456',
    'category': 't-shirt'
  }];
</script>

This datalayer should be defined above your google tag manager script, otherwise these variables or events aren't available for the tag manager. 应在google代码管理器脚本上方定义此数据层,否则这些变量或事件不适用于代码管理器。

If you do want to add variables lateron, after a particular click-event for example, you could add it to the datalayer asynchronously using the following script: 如果您确实希望稍后在特定的单击事件之后添加变量,则可以使用以下脚本异步添加到数据层:

dataLayer.push({'variable_name': 'variable_value'});

If you don't actually know what variables you need to define, you should probably read the magento documentation. 如果您实际上不知道需要定义哪些变量,则应该阅读magento文档。

As per my understanding on Google Tagmanager, You have to define the variable names in the GTM as Macros. 根据我对Google Tagmanager的理解,您必须将GTM中的变量名称定义为宏。 If you don't have the access to google Tagmanager then ask Webmaster or Marketer orwho ever handles it to create the Macros you want. 如果您无法访问Google Tagmanager,请询问网站管理员或营销人员,或者曾经处理过它以创建您想要的宏。 Then you can use the same names in your Magento code. 然后,您可以在Magento代码中使用相同的名称。

Let me know if this answers your question. 如果这回答了你的问题,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM