How to Track Click Events in Shopify (2026)

Last updated
Expert reviewed
5 min read
Jacques Blom
Jacques Blom
CTO at Fudge.

Key takeaways

  • Google Tag Manager’s Click trigger is the easiest way to track specific button clicks without code changes.
  • GA4 Enhanced Measurement automatically tracks outbound link clicks without any setup.
  • For custom button tracking, add data attributes to your buttons and listen for them in JavaScript.
  • Click tracking tells you which CTAs, links, and buttons actually get used - essential for conversion optimization.

Click tracking bridges the gap between page views and purchases. You can see that 1,000 people visited your product page — but without click tracking, you don’t know if 900 of them clicked “Add to Cart” or 90 of them did. That difference completely changes your optimization strategy.

How to track button clicks on a website

Three approaches, from simplest to most flexible:

  1. GA4 Enhanced Measurement — automatic outbound link tracking, no setup needed
  2. Google Tag Manager click triggers — track any specific element without code changes
  3. Custom JavaScript with data attributes — most flexible, works without GTM

Related: Add Google Tag Manager to Shopify.


GA4 automatically tracks clicks on outbound links (links that take visitors to a different domain) when Enhanced Measurement is enabled.

To verify it’s on:

  1. Open GA4 → Admin → Data Streams → select your stream
  2. Under Enhanced Measurement, check that “Outbound clicks” is toggled on

This fires an click event with the link_url parameter for every outbound click. Useful for tracking clicks to partner sites, marketplaces, or affiliate links.

Related: Add Custom Events in Shopify.

Limitation: this only tracks outbound clicks. For clicks within your own store (like “Add to Cart” or “View Details”), you need GTM or custom JavaScript.


Method 2 — Google Tag Manager click trigger

GTM can fire events for any element a visitor clicks — buttons, links, images, or any other clickable element.

Step 1 — Enable GTM’s Click variables. In GTM, go to Variables → Configure. Under Clicks, enable: Click Element, Click Classes, Click ID, Click Target, Click Text, Click URL.

Step 2 — Identify your button. On your live storefront, right-click the button you want to track → Inspect. Note the element’s:

Step 3 — Create a Click trigger in GTM.

Step 4 — Create a GA4 Event tag.

Step 5 — Test with GTM Preview mode. Click Preview → open your store in the new window → click the button. Confirm your tag fires in the GTM debugger.

Step 6 — Submit and publish.


Method 3 — Custom JavaScript with data attributes

For stores without GTM or when you want tracking built directly into a section, data attributes give you clean, maintainable click tracking.

Step 1 — Add data attributes to buttons. In your theme’s Liquid code, add a data-track attribute to the button:

<button
  type="submit"
  class="product-form__submit"
  data-track="add-to-cart"
  data-product="{{ product.title | escape }}"
>
  Add to cart
</button>

Step 2 — Add a click listener. In theme.liquid or a section’s {% javascript %} block:

document.addEventListener('click', function(event) {
  var tracked = event.target.closest('[data-track]');
  if (!tracked) return;

  var action = tracked.dataset.track;
  var product = tracked.dataset.product || '';

  // Send to GA4
  if (typeof gtag !== 'undefined') {
    gtag('event', action, {
      'product_name': product
    });
  }
});

This uses event delegation — one listener on the document catches all tracked clicks, so it works even for elements added dynamically (like quick-add buttons on collection pages).

Add click-tracked conversion elements to your Shopify store.
Try Fudge for Free

To measure results, see create a landing page in shopify.

To measure results, see add a button in shopify.

To measure results, see add a custom conversion element in shopify.


What to track in a Shopify store

Not every click needs tracking. Focus on clicks that tell you something meaningful:

High-value clicks to track:

Less valuable to track:

Ask: “If I knew the click rate on this, would I change something?” If yes, track it.


Viewing click data in GA4

Once click events are flowing:

This data shows which CTAs perform and which don’t — essential for informed conversion rate optimization.

Jacques's signature
Add conversion-focused buttons and CTAs by describing them.

You might also be interested in

How to Add a Custom Conversion Element in Shopify (2026)
Learn how to add countdown timers, urgency bars, trust badges, and sticky CTAs to Shopify — and track their impact on conversions.
How to Track Scroll Events in Shopify (2026)
Add scroll depth tracking to your Shopify store. Fire GA4 events at 25%, 50%, 75%, and 100% scroll using GTM or custom JavaScript.
How to Add Custom Events in Shopify (2026)
Learn how to add custom tracking events in Shopify using the Customer Events API — send data to GA4, Meta, or any pixel. Includes code examples.