Magento 1.7.2 Adwords remarketing tag crashes product view page

163 views Asked by At

I would like to add a dynamic remarketing tag to the View.phtml file. I'm using this code:

<?php $_product = Mage::registry('current_product');?>
<?php if ($_product && $_product->getId()): ?>
<script type="text/javascript">
var google_tag_params = {
ecomm_prodid: '<?php echo $_product->getSku(); ?>',
ecomm_pagetype: 'product',
ecomm_totalvalue: '<?php echo $_product->getfinalprice(); ?>',
}
</script>

This code occupies lines 182 to 190 of my View.phtml file.

When I insert the code into the file, I get the following error message

"Parse Error: syntax error, unexpected $end in (pathfile for view.phtml file) on line 190"

But line 190 is only occupied by the </script> tag

I cannot see any bracket or parenthesis missing or showing up where it shouldn't.

Can somebody please point out to me where the error could be.

3

There are 3 answers

0
Alex Coloma On

I think the last ',' is involved.

Try:

 <script type="text/javascript">
var google_tag_params = {
ecomm_prodid: '<?php echo $_product->getSku(); ?>',
ecomm_pagetype: 'product',
ecomm_totalvalue: '<?php echo $_product->getfinalprice(); ?>'
}
</script>
0
Nolwennig On

+1 Makinovic

and a semi-colon after a variable affectation ?

<?php $_product = Mage::registry('current_product');?>
<?php if ($_product && $_product->getId()): ?>
<script type="text/javascript">
  var google_tag_params = {
  ecomm_prodid: '<?php echo $_product->getSku(); ?>',
  ecomm_pagetype: 'product',
  ecomm_totalvalue: '<?php echo $_product->getfinalprice(); ?>'
};
</script>
0
Code Commander On

When you use the colon syntax with an if statement such as

if ($_product && $_product->getId()):

you need to close with an endif; statement.

Add the following below your </script> tag:

<?php endif; ?>