javascript - WooCommerce OnClick Add to Cart Not Firing? -


I'm trying to fire my Facebook conversion tracking code when someone clicks the Add to Cart button button I made the following changes, though Facebook is still showing pixels as unverified.

I am not sure if there is interference in the onclic event by adding Ajax to the car.

It adds to my cart button:

  echo the apply_filters ('woocommerce_loop_add_to_cart_link', sprintf ('& lt; a href = "% s" rel = "nofollow" "Data-product_id ="% s "data-product_sku ="% s "data-volume ="% s "onclick =" Facebook configured pixel (% s); "class =" button% s product_type_% s "& gt; % S & lt; / a & gt; ', esc_url ($ product - & gt; add_to_cart_url ()), esc_attr ($ Product-> ID), esc_attr ($ product- & gt; get_sku ()), esc_attr (Isset ($ quantity)? $ Quantity: 1), esc_attr ($ product- & gt; Get_price ()), $ product-> is_purchasable () and $ product- & gt; is_in_stock ()? 'Add_to_cart_button ':' ', Esc_attr ($ product-> product_type), esc_html ($ Tpad- & gt; Add_to_cart_text ())), $ product);  

This is part of my loop-start.php file:

  & lt; Script & gt; Function Facebook Conference Pixel (FB_view) {var _fbq = window._fbq || (Window._fbq = []); If (! _fbq.loaded) {var fbds = document.createElement ('script'); Fbds.async = true; Fbds.src = '//connect.facebook.net/en_US/fbds.js'; Var s = document.getElementsByTagName ('script') [0]; S.parentNode.insertBefore (FBDS, S); _fbq.loaded = true; }}) (); Window._fbq = window._fbq || []; Window._fbq.push (['track', '6018460172323', {'value': + fb_value, 'currency': 'USD'}]); } & Lt; / Script & gt; & Lt; Ul class = "Clearfix product of products- & lt ;? php echo $ woocommerce_loop ['column'] ;; & gt;" & Gt;  

I've just added fb_value, I'm not sure I've added it correctly. I tried it without it and still have not verified at the end of Facebook.

Using the following script is information loading on the page and the tracking code and the dollar amount to fire Waiting to join the cart button to apply

  & lt; Script & gt; (Function () {var _fbq = window._fbq || (window._fbq = []); if (! _fbq.loaded) {var fbds = document.createElement ('script'); fbds.async = true; fbds Src = '//connect.facebook.net/en_us/fbds.js'; var s = document.getElementsByTagName ('script') [0]; s.parentNode.insertBefore (fbds, s); _fbq.loaded = true;} }) (); Function Facebook Conference Pixels (FB_view) {window._fbq = window._fbq || []; Window._fbq.push (['track', '6018460172323', {'value': fb_value, 'currency': 'USD'}]); } & Lt; / Script & gt;  

Comments