How can I create unique IDs for each 'Add to Cart' button?

Greetings,

It seems that all the “Add to Cart” buttons on our Shopify store front share the same Button ID information , how would one go about having unique button ids , so I am able to determine the unique items visitors have purchased when it comes to my Google Analytics / Shopify conv

Hi @BotanaFlowers

You can try to add this code to your button code so it will add the ID of the product to the button

id="button-{{product.id}}"

So my button code(s) are as follows , where do you suggest I put in the
id=“button-{{product.id}}” you suggest ?

I take I can modify the product.id , with whatever I want it to illustrate.

[image: Screenshot 2023-11-20 at 8.30.37 AM.png]

Yes this is exactly what i’m looking to do , just questioning the best way to going about adding custom data attributes to the “Add to Cart” button.

@Dan-From-Ryviu had made a suggestion above , just replied to him in determining where exactly I should implement that line of code in my

What theme are you using? You can try to find the add to cart button in product-template.liquid or buy-buttons.liquid (Shopify free theme)

We are leveraging the “Dawn” theme. Unsure which version it is ..
definitely not the latest (12.0) as it’s advising that there is a new
version.

Let me know if you need to the Version , and where I could find that.

[image: Screenshot 2023-11-20 at 8.56.34 AM.png]

You can find Add to cart button in buy-buttons.liquid file

Hey!

So when i click into the buy-buttons.liquid file and do a find on “add”
below is what comes up.

[image: Screenshot 2023-11-20 at 9.17.59 AM.png]

Sorry @Dan-From-Ryviu

Looks like the screenshots i’ve been sending you via email response vs posting directing here don’t seem to display , below is what I see in terms of “add” within the Dawn theme in the buy-button.liquid