'How to trigger Pinterest Add To Cart event only when you click on the add to cart button

I have installed the Pinterest Tag on my ecommerce site on the Product Detail Page. I need the Pinterest tag to trigger the add to cart conversion event ONLY when someone clicks on the add to cart button that is on my page.

The tag is currently tracking the add to cart event as soon as the page loads. So its tracking even when there was no click to the button because its just going based off the page loading. I need it to track only when the button has been clicked.

(Note, I am using the Pinterest Tag Helper Chrome extension. That is how I can visually see that the tag records the ATC event when the page loads and not when I click the button)

What would be the proper jQuery to track this only on click if my code is laid out like this below: Note, the part of the code that reads <img height="1" width="1" is where the trigger is happening for add to cart currently.

<!-- Pinterest Tag -->
<script>
    !function (e) {
        if (!window.pintrk) {
            window.pintrk = function () {
                window.pintrk.queue.push(Array.prototype.slice.call(arguments))
            }; var
                n = window.pintrk; n.queue = [], n.version = "3.0"; var
                    t = document.createElement("script"); t.async = !0, t.src = e; var
                        r = document.getElementsByTagName("script")[0];
            r.parentNode.insertBefore(t, r)
        }
    }("https://s.pinimg.com/ct/core.js");
    pintrk('load', 'MY_PINTEREST_TAG_ID', { em: '<user_email_address>' });
    pintrk('page');
</script>            

<img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=MY_PINTEREST_TAG_ID&event=addtocart&ed[value][email protected]&ed[order_quantity]=1&ed[currency]=USD&noscript=1" />

<!-- end Pinterest Tag -->

I have searched on their documentation but it does not show how a real world application would tie into their code to trigger the event on click from a button, it just shows static values. The link below is where I sort of got this code from the section called: Examples of event data in the IMG tag to copy and paste

https://help.pinterest.com/en/business/article/add-event-codes

This is the code for my button:

    <button class="add-item button-primary" 
    data-item-id="@Model.id"
    data-item-price="@Model.Price"                                                                                       
    data-item-name="@Model.Title">
    Add To Cart
    </button>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source