如何添加脸书像素和转换代码到商店软件5


How to add facebook pixel and conversion code to shopware 5

我使用的是Shopware 5.1.2。我是这个模板系统的新手。

我正在尝试将FB pixcel代码添加到头文件中。所以我在/themes/Frontend/Bare/frontend/index文件夹下创建了fb.tpl

我把它附加到modernizr块:

{extends file='parent:frontend/index/fb.tpl'}
{block name="frontend_index_header_javascript_modernizr_lib" append}
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', 'XXXXXXXXXXXXXX');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=XXXXXXXXXXXXXX&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->
{/block}

我还尝试将fb.tpl添加到特定的主题文件夹中。

并清除了缓存。尽管如此,FB代码在网站上仍然不可见。

将文件移动到响应(或活动主题(主题&将其重命名为header.tpl类似:

/themes/Frontend/Responsive/frontend/index/header.tpl

修改文件内容如下:

{extends file='parent:frontend/index/header.tpl'}
{block name="frontend_index_header_javascript_tracking" append}
{literal}
<!-- Facebook Pixel Code -->
<!-- YOUR Facebook Pixel Code HERE -->
<!-- End Facebook Pixel Code -->
{/literal}
{/block}

从后端菜单执行:

Configuration > Theme Manager > Select Active Theme > Compile Theme

重新加载前端页。它应该起作用!