简体   繁体   English

在Magento中添加Google Remarketing标记的位置

[英]Where to add Google Remarketing tag in Magento

I am trying to figure out in which file I need to add the Google remarketing tag. 我想知道我需要在哪个文件中添加Google再营销代码。 I know it needs to be added before the closing of the body tag. 我知道需要在关闭body标签之前添加它。 Can anyone point me in the right direction? 谁能指出我正确的方向? Thanks 谢谢

here is I did in the past: Depending on what kind of google tracking you are using you have a few different way to use: 这是我过去所做的:根据您使用的Google跟踪类型,您可以使用以下几种方式:

1) If only add a custom code and should be in all the Magento page, use the "Miscellaneous Scripts" value going to admin section, System > Configuration > Design > HTML Head - Miscellaneous Scripts. 1)如果只添加自定义代码并且应该在所有Magento页面中,请使用“其他脚本”值转到管理部分,系统>配置>设计> HTML头 - 杂项脚本。 (This will be included before head closing tag in page HTML.) (这将在页面HTML中的头部关闭标记之前包含。)

2) By native Magento already have Google Analytics tracking code and you can find this configuration going to admin section System > Configuration > Google API - Google Analytics. 2)原生Magento已经拥有Google Analytics跟踪代码,您可以在管理部分系统>配置> Google API - Google Analytics中找到此配置。

3) If you are looking something more complex and use the Google adWords I used the extension magento connect link . 3)如果您正在寻找更复杂的东西并使用Google adWords,我使用了扩展名magento connect链接 For a particular Client I did some extra modification to include some extra code if a client subscribe to newsletter or a new client etc. 对于特定客户,我做了一些额外的修改,以便在客户订阅时事通讯或新客户等时包含一些额外的代码。

I hope you can find something helpfully in the post. 我希望你能在帖子中找到有用的东西。

Best, GrinGo. 最好的,GrinGo。

There are different template file for different pages in magento so at first I think you should decide where to place it.For example if you want to place it in footer than you should place that code snippet in magento中的不同页面有不同的模板文件,所以首先我认为你应该决定放置它的位置。例如,如果你想把它放在页脚中,那么你应该放置该代码片段

"app/design/frontend/base/default/page/html/footer.phtml" “应用程序/设计/前端/基/默认/页/ HTML / footer.phtml”

Similarly you can check other different template files to place your code. 同样,您可以检查其他不同的模板文件来放置代码。

NB:Best practice is to overide the core file of magento before making changes to it. 注意:最佳做法是在更改之前覆盖magento的核心文件。

Hope this will help. 希望这会有所帮助。

There's no indication as to which Magento version you're using 1 or 2. At the end of the day it depends how much technical knowledge you have and if you're using a version control system to manage your Magento build. 没有迹象表明你使用的是哪个Magento版本1或2.在一天结束时,它取决于你拥有多少技术知识,以及你是否使用版本控制系统来管理你的Magento版本。

  • Miscellaneous Scripts as another answer mentioned earlier, this approach is straight forward and very easy to use to plug and play your code. 杂项脚本作为前面提到的另一个答案,这种方法很简单,很容易用来插入和播放你的代码。
  • Google Module depending which version of Magento you use (CE/EE) there will be a built-in section for you to plugin your account ID in backend Magento configuration and then the platform will generate necessary code for you. 谷歌模块取决于您使用的Magento版本(CE / EE),将有一个内置部分供您在后端Magento配置中插入您的帐户ID,然后该平台将为您生成必要的代码。
  • Write custom module by writing your own module you can place it the snippet anywhere on the page by targeting before_body_end node in your layout XML file. 通过编写自己的模块来编写自定义模块 ,您可以通过在布局XML文件中定位before_body_end节点将其放在页面的任何位置。 This is more technical but gives you more control over what you can do. 这更具技术性,但可以让您更好地控制自己可以做的事情。
  • Google Tag Manager this also depends on if your Magento version comes pre-built with Google Tag Manager module, then you can create a container and place all your logic in there. Google跟踪代码管理器还取决于您的Magento版本是否预先构建了Google跟踪代码管理器模块,然后您可以创建容器并将所有逻辑放在那里。 This is also more technical and require the output of some values in JS format on the frontend to let GTM read the values. 这也是技术性的,需要在前端输出JS格式的一些值,让GTM读取值。

At the end of the day go with what is easy to setup, portable and easy to manage . 在一天结束时,可以轻松设置,便携和易于管理 I usually go with Google Tag Manager as it takes time to create initial setup of exposing data on the frontend but then I have full control of what I want to do with that data through tag manager. 我通常使用Google跟踪代码管理器,因为需要时间来创建在前端公开数据的初始设置,但之后我可以通过标记管理器完全控制我想要对该数据执行的操作。 In most cases you'll end up using the same data (ex. totals, shipping method, product IDs, SKUs, cost, etc.) in more than one third party API so this gives you flexibility to do just that. 在大多数情况下,您最终会在多个第三方API中使用相同的数据(例如总计,运输方式,产品ID,SKU,成本等),这样您就可以灵活地执行此操作。

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

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