Skip to content

Instantly share code, notes, and snippets.

@alewolf
Last active April 22, 2022 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alewolf/8fbf2f44f934f287967b4c7819112520 to your computer and use it in GitHub Desktop.
Save alewolf/8fbf2f44f934f287967b4c7819112520 to your computer and use it in GitHub Desktop.
<?php
/**
* Track custom add-to-cart conversions using the WooCommerce Pixel Manager
*
* Add this to your functions.php file
*/
add_action('wp_footer', function () {
?>
<script>
jQuery(document).on("wpmAddToCart", function (event, product) {
gtag("event", "conversion", {
send_to : "CONVERSION_ID/CONVERSION_LABEL",
// any value you want or
value: 0.00,
// you could also calculate the product price times product quantity
value: product.price * product.quantity,
currency: "USD",
})
})
</script>
<?php
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment