What sort of function can I use to Call gtag_report_conversion on
Wanting to track 'Add to Cart' clicks on a WooCommerce store & Google Ads tell me I need to call gtag_report_conversion
when any 'Add to cart' button is clicked on the site.
Some buttons are a link <a href="... etc">
using class="add_to_cart_button"
- see example page
While other buttons are a <button>
tag using class="single_add_to_cart_button"
- see example page
I see from Google's instructions that the structure for a link is:
<a onclick="return gtag_report_conversion('http://example.com/your-link');"href="http://example.com/your-link">Add To Cart</a>
And the structure for a <button>
tag is:
<button onclick="return gtag_report_conversion('http://example.com/your-link')">Add To Cart</button>
How can I construct a function hook that will create the above link / button tag structure & would it be an action or filter hook? Also, is it possible to use the classes mentioned earlier to define which buttons on the site should be affected by this particular function. The documentation showing what action & filter hooks are available for WooCommerce is here.