This article is about Google Analytics 4 properties. Refer to the Universal Analytics section if you're still using a Universal Analytics property, which will stop processing data on July 1, 2023 (July 1, 2024 for Analytics 360 properties).

[GA4] Minimize duplicate conversions with transaction IDs

A transaction ID is a unique identifier that you can create for each transaction, such as an order confirmation number. By adding a transaction ID to each ecommerce event, you can avoid counting duplicate conversions from the same user.

Conversion events are events that measure valuable actions on your site or app. You can measure any event as a conversion in Google Analytics. When someone completes a valuable action, a conversion should only be counted once. However, if a customer returns to a page or screen with a conversion event on it or reloads the page or screen, it's possible that the same conversion is registered twice, and the second load could be counted for the same order.

To avoid these duplicate conversions, you can edit your ecommerce events to capture a unique transaction ID, such as an order confirmation number you may already be using. If there are 2 conversions for the same conversion action with the same transaction ID, Google Analytics will know that the second conversion is a duplicate and the duplicate conversion won’t be counted.

Google Analytics only de-duplicates transactions with the same transaction ID from the same user. The same transaction ID can be used for different users without de-duplicating the transactions.

Note: Make sure you’re passing a dynamic value for the transaction ID. If your tag sends Google Analytics the same ID for different transactions, you could significantly undercount your conversions.
Important: Do not send an empty string as the transaction ID. Google Analytics will deduplicate all purchase events that have transaction_id="".

Before you begin

The transaction ID must be unique for each order. For example, you could use the order confirmation numbers for your transactions.

The transaction IDs can include numbers, letters, and special characters like dashes or spaces. They must be unique for each transaction. The transaction IDs must omit any information that could be used to identify individual customers.

Add a transaction ID

You need to modify your code to collect the transaction ID. You don't need to make any changes in Google Analytics.

Note: Make sure you pass a dynamic value for the transaction ID. If you send the same ID for different transactions, then you could significantly undercount your conversions.

As an example, the following instructions use Active Server Pages (ASP) and update the gtag.js measurement code . The exact code will vary depending on the server language you use. Make sure to use the right language for your website.

  1. Open the ASP file (or the appropriate file for the server language you use) for your conversion page.
  2. Find the ASP expression that stores that information. For example: <%= orderId %>.
  3. Open the HTML for your conversion page, and find your event snippet.
  4. In the script section of the event snippet (between the <script></script> tags), replace <%= orderId %> with the ASP expression you found in step 2:

    Event snippet example:

         gtag('event', 'purchase', {
          transaction_id: '<%= orderId %>',
          value: 25.42,
          currency: "USD",

Verify the transaction ID

  1. Trigger the event on your website.
  2. In your web browser, view the source of the webpage. (In most browsers, right-click the page and select View source).
  3. You should see the measurement code between the <head> and </head> tags on your page. The ASP expression will be replaced by the actual transaction ID.
Was this helpful?
How can we improve it?

Need more help?

Sign in for additional support options to quickly solve your issue

Choose your own learning path

Check out, a new resource to help you get the most out of Google Analytics 4. The new website includes videos, articles, and guided flows, and provides links to the Google Analytics Discord, Blog, YouTube channel, and GitHub repository.

Start learning today!

Clear search
Close search
Google apps
Main menu
Search Help Center