2012-05-03 38 views
0

谷歌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 
} 
?> 

你能幫助?

回答

0

您遺漏了您的ga _addTrans_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 
} 
?>