Facebook客户聊天插件实施与标记管理器错误

时间:2018-03-15 14:14:42

标签: facebook facebook-javascript-sdk google-tag-manager facebook-messenger

工作解决方案

this article by Simoa Hava

上找到答案

问题

我们使用GTM实施了Facebook客户聊天。虽然版本2.11工作正常,但v2.12不起作用,因为它不允许我添加下面的代码

Implementation guidelines

<!-- Load Facebook SDK for JavaScript -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = 'https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.12&autoLogAppEvents=1';
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<!-- Your customer chat code -->
<div class="fb-customerchat"
  page_id="xxxxxxxxxxxxxx"
  theme_color="#921710"
  logged_in_greeting="Hi! Got any questions? Ask us anything, or get stuck in for more inspiration!"
  logged_out_greeting="Hi! Got any questions? Ask us anything, or get stuck in for more inspiration!">
</div>

我得到的错误是

  

模板中找到无效的HTML,CSS或JavaScript。

以前的工作代码:

    <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId            : 'xxxxxxxxxxxxxx',
          autoLogAppEvents : true,
          xfbml            : true,
          version          : 'v2.11'
        });
      };

      (function(d, s, id){
         var js, fjs = d.getElementsByTagName(s)[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement(s); js.id = id;
         js.src = "https://connect.facebook.net/en_US/sdk.js";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'facebook-jssdk'));

  jQuery('body').append('<div class="fb-customerchat" page_id="xxxxxxxxxx" minimized="false"> </div>');

    </script>

使用jQuery更新代码 - 仍显示错误

<!-- Load Facebook SDK for JavaScript -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = 'https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.12&autoLogAppEvents=1';
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<!-- Your customer chat code -->
jQuery('body').append('<div class="fb-customerchat" page_id="xxxxxxxxxxx" theme_color="#921710" logged_in_greeting="Hi! Got any questions? Ask us anything, or get stuck in for more inspiration!" logged_out_greeting="Hi! Got any questions? Ask us anything, or get stuck in for more inspiration!"  minimized="true"></div>');

任何帮助将不胜感激:)

0 个答案:

没有答案