0

Google Chrome デバッガーは、次の GA eCommerce トラッキング コードで SyntaxError: Unexpected Identifier を示します。

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

お手伝いできますか?

4

1 に答える 1

0

_addTransgaと_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  
}
?>  

于 2012-09-22T16:33:30.453 に答える