Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google analytics SyntaxError:意外的标识符。谷歌电子商务跟踪代码的谷歌Chrome调试器_Google Analytics - Fatal编程技术网

Google analytics SyntaxError:意外的标识符。谷歌电子商务跟踪代码的谷歌Chrome调试器

Google analytics SyntaxError:意外的标识符。谷歌电子商务跟踪代码的谷歌Chrome调试器,google-analytics,Google Analytics,google chrome调试器在以下GA电子商务跟踪代码中显示SyntaxError:意外标识符: <?php if($this->tx_id == true && $this->rd['total'] == true) { ?> _gaq.push(['_addTrans', <?=$this->tx_id ?>, '',

google chrome调试器在以下GA电子商务跟踪代码中显示SyntaxError:意外标识符:

<?php 
if($this->tx_id == true && $this->rd['total'] == true) { 
?>
    _gaq.push(['_addTrans',
                    <?=$this->tx_id ?>,
                    '',
                    <?=$this->rd['total']?>,
                    '',
                    '',
                    '',
                    '',
                    ''
                ]);

    <!------Items purchased------>
<?php 
    foreach($this->dd as $sku=>$val) {
        $i++;
        $product_title= $this->pp[$sku]['title'];
        $qty = $val['pt']['qty']; 
        ?>
            _gaq.push(['_addItem',
                        <?= $this->tx_id ?>,
                        <?= $sku ?>,
                        <?= $this->pp[$sku]['title'] ?>, 
                        '',
                        <?= $this->pp[$sku]['price']?>,
                        <?= $qty ?>
                    ]);
    <?php 
    }
    ?>

    _gaq.push(['_trackTrans']);  
<?php  
}
?>  

您是否能够提供帮助?

您缺少ga\u addTrans和\u addItem命令参数周围的单引号

应该是这样写的:

<?php 
if($this->tx_id == true && $this->rd['total'] == true) { 
?>
    _gaq.push(['_addTrans',
                    '<?=$this->tx_id ?>', /* <-- Surrounded with single quotes */
                    '',
                    '<?=$this->rd['total']?>', /* <-- Surrounded with single quotes */
                    '',
                    '',
                    '',
                    '',
                    ''
                ]);

    <!------Items purchased------>
<?php 
    foreach($this->dd as $sku=>$val) {
        $i++;
        $product_title= $this->pp[$sku]['title'];
        $qty = $val['pt']['qty']; 
        ?>
            _gaq.push(['_addItem',
                        '<?= $this->tx_id ?>', /* <-- Surrounded with single quotes */
                        '<?= $sku ?>', /* <-- Surrounded with single quotes */
                        '<?= $this->pp[$sku]['title'] ?>',  /* <-- Surrounded with single quotes */
                        '',
                        '<?= $this->pp[$sku]['price']?>', /* <-- Surrounded with single quotes */
                        '<?= $qty ?>' /* <-- Surrounded with single quotes */
                    ]);
    <?php 
    }
    ?>

    _gaq.push(['_trackTrans']);  
<?php  
}
?>