将Google Ads转换代码段添加到Prestashop

时间:2018-11-13 10:36:37

标签: prestashop google-tag-manager prestashop-1.6 google-adwords

我正在按照说明进行操作,以使其与正式的Google文档一起使用,并且在将代码段插入订单确认模板时遇到了问题:

  1. 首先,它说我必须将其插入标头中,而在此模板中这是不可能的,因此我要将其添加到正文的底部,或者我对此有误吗?

  2. 代码段本身:

    <!-- Event snippet for Compra Realizada conversion page -->
    <script> 
    {literal}
    gtag('event', 'conversion', { 'send_to': 'AW-XXXXXXXXX/hFH0CLjs_mwQhvnEowM', 'transaction_id': '{$id_order_formatted}' });
    {/literal}
    </script> 
    

似乎转换不正确吗?上面的代码正确吗?

1 个答案:

答案 0 :(得分:0)

我看到您是西班牙语,我认为您必须用西班牙语更好地理解我: 您正在添加AG的标头,但未定义事件

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX-X"></script>

Gtag加载在声明头部的AG标签之后:

 <script>
      window.dataLayer = window.dataLayer || [];
            function gtag(){dataLayer.push(arguments);}
             gtag('js', new Date());

             gtag('config', 'UA-XXXXX-X');
 </script>

然后调用将在其相应功能中运行的事件,包括单击,加载,mouslistener等:

<script>    
      gtag('event','formSend'});
</script>

示例:

    <!DOCTYPE html>
<html>
<head>
    <title>Prueba</title>
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX-X"></script>
    <script>
          window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments);}
                 gtag('js', new Date());

                 gtag('config', 'UA-XXXXX-X');
     </script>
</head>
<body>
    <a id="foo" href="javascript:void(0)">Send Info</a>
    <script>
        function sendGat() {
            gtag('event','formSend');
            console.log("Gat Send");
        }
        document.addEventListener( 'DOMContentLoaded', function () {
            var bar = document.getElementById("foo").addEventListener("click", sendGat);
        }, false );
    </script>
</body>
</html>