How to Track Coupon Codes in Google Analytics

Cody Schneider8 min read

Wondering if your "SAVE20" promo code is actually making you money or just costing you margin? Tracking coupon code performance is essential to understanding your marketing ROI, but getting that data into Google Analytics can feel like a puzzle. This article will show you exactly how to track coupon codes in Google Analytics 4 so you can see which promotions are genuinely driving your business forward.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Why Bother Tracking Coupon Codes?

Tracking the number of times a coupon is used is just the start. When you properly connect this data to Google Analytics, you unlock a much deeper level of insight that helps you make smarter marketing and sales decisions.

  • Measure True ROI: Don't just guess if a campaign was successful. By tying coupon usage directly to revenue, transactions, and user acquisition data in GA4, you can calculate the actual return on investment for each specific promotion.
  • Identify Your Best-Performing Campaigns: Is your influencer collaboration code ("INFLUENCER15") outperforming your email newsletter promotion ("EMAIL10")? By tracking codes individually, you can double down on the campaigns, channels, and offers that resonate most with your audience.
  • Understand Customer Behavior: Learn more about your deal-seeking customers. Do customers who use coupons have a higher average order value because they feel they're getting a deal? Or do they only buy the discounted item? This data can inform your entire promotional strategy.
  • Optimize Your Marketing Channels: If you use unique coupon codes for different channels (e.g., one for Facebook Ads, another for your affiliate partners), you can attribute revenue with pinpoint accuracy and allocate your marketing budget more effectively.

The Best Method: E-commerce Event Tracking

The most accurate and recommended way to track coupon codes is by sending the data directly to Google Analytics as part of your e-commerce purchase event. Essentially, whenever a customer completes a purchase on your site, you’ll also send GA4 the specific coupon code they used.

Sounds technical, but it's simpler than you think. Most modern e-commerce platforms handle this fairly easily.

How an E-commerce Setup Works

Regardless of your platform, the process follows the same logic:

  1. A visitor adds items to their cart and proceeds to checkout.
  2. They enter a discount code like SUMMER25 and the discount is applied.
  3. They complete the purchase.
  4. Your website’s backend code bundles up all the transaction data - including product names, prices, transaction ID, total revenue, and crucially, the coupon code used.
  5. This bundle of data is sent to Google Analytics 4 as a purchase event.

Let's look at how to ensure this happens on a few popular platforms.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

For Shopify Stores

If you have a Shopify store, you're in luck. Shopify’s native integration with Google Analytics 4 typically handles this for you automatically. When you connect your GA4 property to your Shopify admin, the script that gets added to your site is already configured to pass the coupon data with every purchase.

You shouldn't need any custom coding. The key is to simply ensure your GA4 integration is set up correctly in the Shopify admin panel under Online Store > Preferences > Google Analytics.

For WooCommerce (WordPress) Stores

For those using WordPress and WooCommerce, your best bet is to use a plugin that streamlines the GA4 integration. These plugins handle the complex task of creating a "data layer" (a snippet that holds all your e-commerce data) and sending it to GA4.

Popular choices include:

  • GTM4WP (Google Tag Manager for WordPress): This powerful plugin is a favorite among marketers. Once installed, go to its settings under Integration > WooCommerce and make sure "Track enhanced e-commerce" is enabled. It will automatically detect coupon code usage and add it to the data layer for you.
  • Analytify, MonsterInsights, or similar plugins: Most major analytics plugins for WordPress offer robust WooCommerce integrations. Check their e-commerce settings to ensure that coupon tracking is enabled.
GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

The Custom Method: Using Google Tag Manager (GTM)

If your e-commerce platform doesn’t automatically send coupon data, or if you prefer a more hands-on approach, Google Tag Manager is your best friend. This method requires your developer to expose the coupon code in the website's data layer.

Step 1: The Data Layer

First, you need the coupon code to be available in the data layer when a purchase is made. A data layer is a structured format for your website data that GTM can easily understand. Ask your developer to implement a data layer snippet on your order confirmation page that looks something like this:

window.dataLayer = window.dataLayer || [],
window.dataLayer.push({
  'event': 'purchase',
  'ecommerce': {
    'transaction_id': 'T-12345',
    'value': 85.00,
    'currency': 'USD',
    'coupon': 'SAVE15',
    'items': [{
      'item_name': 'Cool T-Shirt',
      'item_id': 'SKU-001',
      'price': 100.00,
      'quantity': 1
    }]
  }
}),

The most important part here is the 'coupon': 'SAVE15' line. This makes the used coupon available for GTM to grab.

Step 2: Create a GTM Variable

Now, you need to tell GTM how to capture that coupon code from the data layer.

  1. In your Google Tag Manager container, go to Variables and click New under "User-Defined Variables."
  2. Choose Data Layer Variable as the variable type.
  3. In the "Data Layer Variable Name" field, enter ecommerce.coupon. This tells GTM to look inside the 'ecommerce' object for the 'coupon' key.
  4. Name your variable something memorable, like "DLV - ecommerce - coupon," and save it.

Step 3: Add the Variable to Your GA4 Event Tag

Finally, you'll attach your new variable to your main GA4 purchase tag.

  1. Go to Tags and find your primary GA4 tracking tag - it's likely called "GA4 Event - Purchase" or something similar.
  2. Click on the tag to edit it, and expand the Event Parameters section.
  3. Click Add Row.
  4. For the "Parameter Name," type coupon. This must be spelled exactly this way, all lowercase.
  5. For the "Value," click the lego brick icon and select the {{DLV - ecommerce - coupon}} variable you just created.
  6. Save your tag. Don't forget to Submit and Publish your container changes in GTM.

Creating a Custom Dimension in GA4

You've successfully started sending coupon data to GA4, but there's one more essential step. By default, GA4 collects the 'coupon' parameter, but you can't use it in your standard reports until you register it as a Custom Dimension.

Here's how to do it:

  1. In your Google Analytics 4 property, navigate to Admin (the gear icon on the bottom left).
  2. In the "Property" column, find Custom Definitions and click on it.
  3. Click the big blue button labeled Create Custom Dimensions.
  4. Fill out the configuration:
  5. Click Save.

That's it! Keep in mind it can take up to 48 hours for data to start flowing into reports with this new dimension, so be patient.

How to See Your Coupon Data in GA4 Reports

Now for the fun part: analyzing the data. There are two primary places in GA4 to build reports to see how your coupons are performing.

1. Add to Standard E-commerce Reports

The simplest way to see your data is by adding the custom dimension to the built-in e-commerce report.

  • Go to Reports > Monetization > E-commerce purchases.
  • You'll see a table of your products sold. To see this data broken down by coupon code, click the little blue + icon next to the primary dimension (which is usually "Item name").
  • A search box will appear. Type "Coupon Code" and select the custom dimension you created earlier.
  • The report will reload, showing you transaction and revenue data broken down by both the item and the coupon code used to purchase it.
GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

2. Build a Custom Report in "Explore"

For more control and flexibility, GA4’s "Explore" section is the perfect tool. You can build a clean, dedicated report just for your coupon data.

  1. Go to the Explore tab in the left-hand navigation and start a new Free form exploration.
  2. In the "Variables" column on the left, you'll need to import the data you want to use:
  3. Now, build your report in the "Tab Settings" column:

Instantly, you’ll have a clear table showing the performance of every single coupon code. You can easily see which codes are driving the most revenue and transactions, helping you identify your top-performing promotions at a glance.

Final Thoughts

Following these steps - sending coupon data with your e-commerce events and registering it as a custom dimension - give you the power to properly measure the impact of your promotions. You can move beyond simple redemption counts and start making data-driven decisions about discounts, channels, and campaigns that build a more profitable business.

Once you’re set up, building these reports in GA4 is a great starting point, but it still requires some manual work to get to the answers you need. At Graphed, we created a way to skip the report-building altogether. We connect directly to your Shopify, Google Analytics, and other marketing platforms in a few clicks. Then you can just ask in plain English for what you need - like, "Compare my revenue from coupons 'SUMMER20' vs 'EMAIL10' last quarter" - and get an answer instantly. It automates away the reporting friction and gets you right to the insights that help you grow.

Related Articles