scenario: tracking events(add cart, search terms, product views, etc) test e-commerce website(opencart), javascript function written in footer page , these functions called @ button triggers or page loads. problem: while tracking product view event following code added product page, function captureproductview() called footer, , parameters clientid, fname, lname retrieved getclientdetails(); <script> window.onload=function(){ getclientdetails(); captureproductview('<?php echo $product['product_id']; ?>', '<?php echo $product['name']; ?>', '<?php echo $product['price']; ?>', clientid, fname, lname); }; </script> but values php variables $product['product_id'] , $product['name'] , $product['price'] cannot parsed script tag, leaving notice: notice : undefined variable: product in /home/path.../product.tpl on line 29 "...