Skip to content

Instantly share code, notes, and snippets.

@chexton
Last active December 25, 2015 21:09
Show Gist options
  • Save chexton/7040883 to your computer and use it in GitHub Desktop.
Save chexton/7040883 to your computer and use it in GitHub Desktop.
<script>
var products = [];
<?php
var products = //Array of products
foreach ($products as $product) { ?>
// Add the product to the JS array
products.push({
name: "<?php $product['name'] ?>",
price: "<?php $product['price'] ?>"
});
<?php } ?>
// Track the event with the product meta-data after you've got them in the array
_veroq.push(['track', 'begins checkout', {products: products}]);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment