Use a transaction ID to minimize duplicate conversions

The transaction ID must be unique for every single transaction and must be dynamically generated by your website's backend or e-commerce platform for each purchase. Hardcoding the same ID, using static values, or failing to ensure uniqueness across transactions will lead to significant undercounting of conversions, as Google Ads may only process the first instance of a given Transaction ID.

Unique transaction IDs, such as order confirmation numbers, are essential for accurate conversion measurement, especially for purchases. They prevent duplicate conversions and enable advanced measurement features.

Use transaction IDs for tracking online and offline conversions.

If you add your conversion tracking tag to a conversion page , such as an order confirmation page, then a conversion should only be counted when a customer has completed a valuable action on your website. However, if a customer returns to the conversion page or reloads the page, it’s possible that the same tag could fire again, and a second conversion could be counted for the same order.

To avoid these duplicate conversions, you can edit your conversion tracking tag 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 Ads will know the second conversion is a duplicate. You'll get an error message, and the duplicate conversion won’t be counted.

To improve your conversion measurement, we strongly recommend uploading online conversions you stored in the backend, for example in your CRM, using Data Manager in addition to the Google tag. When doing so, the transaction ID should be consistent across both the tag and server-to-server uploads. This helps you to boost conversion tracking. You can read more here .

In this article, we’ll explain how to add a unique transaction ID to your conversion tracking tag and how to use it with offline conversions.

Note: The term "order ID" is used instead of transaction ID in the context of offline conversions, including offline conversion adjustments and enhanced conversions for leads. If you use one of these products, you'll use the "Order ID" field to specify the unique ID for a conversion in your CSV uploads or API code.

On this page


Before you begin

Before you can add transaction IDs to your conversion tracking tag, you’ll need the following:

  • Conversion tracking set up for your website . To follow the instructions below, you’ll need to have created a conversion action in your Google Ads account and added the conversion tag to your website.
  • Your website should be able to generate unique transaction IDs, such as order confirmation numbers for your transactions. The transaction IDs can include numbers, letters, and special characters like dashes or spaces, with a character limit of 64 characters. It’s critical that each transaction ID is unique to each individual order. Using the same ID for multiple orders will result in undercounting. The transaction IDs must not include any information that could be used to identify individual customers.
  • Depending on your setup, you may require the ability to edit code on your website. Either you or your web developer will need to edit the conversion tracking tag.

Instructions

You’ll need to add a piece of code to your conversion tracking tag to pull the unique order number and send it along in your tag. You don’t need to update anything in your Google Ads account, just update your tag.

Keep in mind

Make sure you’re passing a dynamic value for the transaction ID. If your tag sends Google Ads the same ID for different transactions, you could significantly undercount your conversions.

Set up transaction IDs through the Google tag event snippet

Step 1 of 3: Generate and expose the Transaction ID

When a conversion occurs, for example, a customer completes a purchase, your server should generate a unique transaction ID. You can then make this ID available in the HTML of your conversion confirmation page. This is commonly done by rendering the ID directly into a JavaScript variable on the page.

For example, on a confirmation page, your server-side code might generate a snippet like this:

<script>
  const uniqueTransactionId = 'TID_1663445995_789'; // This value should be dynamically generated by your server
</script>

Step 2 of 3: Pass the ID in your Google tag event snippet

Next, modify your Google tag event snippet to pass this dynamically generated ID. Find your event snippet on the conversion page and add the transaction_id parameter, using the variable you defined in the previous step.

// This variable should be populated with the unique ID from your server
const uniqueTransactionId = 'TID_1663445995_789';

gtag('event', 'conversion', {
  'send_to': 'AW-CONVERSION_ID/CONVERSION_LABEL',
  'value': 120.50,
  'currency': 'USD',
  'transaction_id': uniqueTransactionId // Here's the unique ID
});

Step 3 of 3: Verify your implementation

After deploying the code, make a test purchase on your site. You can then use Tag Assistant to verify that the transaction ID is being passed correctly on the conversion ping.

Set up transaction IDs through Google Tag Manager

For advertisers using Google Tag Manager, the most reliable way to pass a unique transaction ID is by using your website's data layer. The process involves two main stages: ensuring your website's developer pushes the ID to the data layer, and then configuring Google Tag Manager to read that ID and pass it to Google Ads.

Part 1: Pushing the Transaction ID to the Data Layer (for your web developer)

Before you can configure Google Tag Manager, your web developer must update your website's code to push the unique transaction ID to the data layer whenever a conversion occurs. This makes the value available for Google Tag Manager to capture.

Here is an example of the code your developer would add to the conversion confirmation page.

<script>
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    'event': 'purchase', // A custom event name to trigger your GTM tag
    'transaction_id': 'UNIQUE_TRANSACTION_ID_FROM_YOUR_SYSTEM' // The dynamic transaction ID
  });
</script>

Key points for your developer:

  • The transaction_id must be populated dynamically with a unique value for every order.
  • Pushing a custom event, such as purchase is a best practice, as it provides a clear signal that you can use to fire your Google Ads tag in Google Tag Manager.

Part 2: Configuring Google Tag Manager

Once the data layer is correctly implemented, follow these steps in your Google Tag Manager container.

Step 1 of 4: Create a Trigger

First, create a trigger that will fire your Google Ads tag when the purchase event occurs.

  1. In your Google Tag Manager workspace, go to Triggersand click New.
  2. Name your trigger. For example, "Custom Event - Purchase".
  3. For the "Trigger Configuration," choose Custom Event.
  4. In the "Event name" field, enter the name of the event your developer pushed to the data layer, such as purchase for example.
  5. Click Save.

Step 2 of 4: Create a Data Layer Variable

Next, create a variable that will capture the transaction ID from the data layer.

  1. Go to Variablesand, in the "User-Defined Variables" section, click New.
  2. Name your variable. For example, "DLV - transaction_id".
  3. For the "Variable Configuration," choose Data Layer Variable.
  4. In the "Data Layer Variable Name" field, enter transaction_id . This must exactly match the key used in the dataLayer.push() code.
  5. Click Save.

Step 3 of 4: Update Your Google Ads Conversion Tracking Tag

Finally, configure your Google Ads Conversion Tracking tag to use the variable you just created.

  1. Go to Tagsand click on your existing Google Ads Conversion Tracking tag or create a new one if you haven't already.
  2. In "Tag Configuration," find the Transaction ID field.
  3. Click thevariable selector iconbutton next to the field and select the Data Layer Variable you created in the previous step. For example, {{DLV - transaction_id}} .
  4. Under "Triggering," select the trigger you created in Step 1. For example "Custom Event - Purchase".
  5. Click Save.
  6. Publish your Google Tag Manager container to make the changes live.

By following these steps, Google Tag Manager will dynamically pull the unique transaction ID from the data layer with every purchase and send it to Google Ads.

Step 4: Verify Your Implementation

After you have configured your tag and published your Google Tag Manager container, you should verify that the transaction ID is being captured and passed correctly. The best way to do this is with the built-in Preview mode in Google Tag Manager.

  1. Start preview mode: In your Google Tag Manager workspace, click the Preview button in the top-right corner. Enter the URL of your website and click Connect. This will open your website in a new browser tab with the Tag Assistant debug pane at the bottom.
  2. Complete a test conversion: On your website, go through the process of making a test purchase to trigger the conversion event.
  3. Check the tag firing: In the Tag Assistant window or tab, you should be able to observe the custom event you created, such as purchase , appear on the left-hand side event timeline. Click on this event.
  4. Inspect the Google Ads Tag: In the "Tags Fired" section for that event, you should be able to observe your Google Ads Conversion Tracking tag. Click on the tag to open its details.
  5. Verify the Transaction ID: In the tag details, you will see the exact values that were passed to Google Ads. Look for the "Transaction ID" field and confirm that it shows the unique ID that was generated for your test purchase. It should not be a static value or show as "undefined".
  6. Repeat the test: To ensure the ID is dynamic, perform another test purchase and verify that a new and different transaction ID is captured.

Set up transaction IDs using a content management system (CMS)

For content management systems (CMS) with deep integration with Google, your purchase conversions or events may already be sending transaction IDs. For example, Shopify automatically includes transaction IDs with its conversions through the Google & YouTube app .

If your CMS or e-commerce platform lacks direct Google integration but offers API access, you may manually retrieve the transaction ID. Check your platform's documentation. You may find the transaction ID in a global JavaScript variable or data layer, or need to fetch it through their server-side API and then pass it to the frontend for the tag to use.

Set up transaction IDs for offline conversions

When you import conversions from ad clicks , you can optionally add a unique transaction ID in the transaction ID (or order ID) column. If you’re setting up transaction IDs for additional data sources, the transaction ID is required. For Offline Conversion Import (OCI), the transaction ID is optional, but it’s best practice to include it for purchase conversions.

Set up transaction IDs for conversions with multiple data sources

If you’re connecting another data source to supplement your website conversions with additional data through Data Manager, it’s essential to collect a unique transaction ID for each purchase.

The ID from your new data source must exactly match the transaction_id captured by your conversion tag. Discrepancies such as different prefixes, suffixes, or extra spaces, will prevent Google Ads from deduplicating events and reporting your conversions accurately.


Verify your transaction ID implementation in the Google tag

You can use Google Tag Assistant to check if the transaction ID is being correctly sent. While making a test purchase, use Tag Assistant to ensure the “Transaction ID” field in your Google Ads tag fire contains a unique value.

Transaction ID in Google Tag Assistant

Verify the conversion ping using Chrome Developer Tools

You can also use Chrome Developer Tools to verify the conversion ping.

  1. In Google Chrome, right-click anywhere in your website, then select Inspect.
  2. Go to the Networktab and look for the &oid= parameter in the request to https://www.googleadservices.com/pagead/conversion
  3. Confirm if it has a unique value for each order.

Transaction ID coding errors

While transaction IDs help avoid counting duplicate conversions, if transaction IDs are incorrectly coded, conversions can be marked as invalid or Google Ads may skip the deduplication process if it finds the same transaction ID used by multiple customers.

Here are some examples of coding errors:

Failed dynamic variables

Your server-side code uses variables to dynamically provide a unique transaction ID. If the snippets that represent these variables fail to resolve, you may get errors. Here are some example snippets:

  • {{ order_number }}
  • [invoice-prefix][invoice-number]
  • null-user-id
  • gtm.init
  • <%= orderId %>
  • [object Object].transaction_id
  • <google_ads_transaction_id>
  • Number(order.id).toString()
  • <?php echo $order->id; ?>
  • <b>Notice</b>: Undefined variable: order_id in <b>/home/sovua/fitodar.com.ua/www/catalog/view/theme/default/template/common/success.tpl</b> on line <b>66</b>

Example

If you used {{ order_number }} in your Google tag event snippet, but your server-side variable is {{order_number}} with no extra spaces, it won’t be able to populate the transaction ID. It will only result in the {{ order_number }} variable showing up instead of the actual ID.

Placeholder values

These are strings or fixed numbers that are generic or meant as static test values or labels that shouldn’t be used as transaction IDs:

  • button-confirm
  • congrats
  • thank_you
  • not set
  • buy
  • Page View
  • Conversion Tracking Google Ads
  • 1234
  • https://www.google.com/
  • Google

Irrelevant data types

These are data types and values that shouldn’t be used as transaction IDs:

  • URLs
    • www.example.com
    • https://www.example.org/admin/
    • example.com
    • https://www.example.com/products
  • Email addresses
    • ...@gmail.com
    • ...@yahoo.com
    • Custom domains
  • Prices or currency
    • $17.99
    • $ 5.37
    • $ 21.45
    • $ 15.50
    • USD
    • AUD
  • Hashed or UUID strings
    • 50d858e0985ecc7f60418aaf0cc5ab587f42=
    • G-1234567890
    • e9891562113d8a62add1bf
    • 0888-af2bdbe1aa9b6ec1e
  • Products
    • /products/dog-proof-fence-pack-timber-fences
    • /shop/product/electric-toothbrush
    • Product Pro_trial_monthly_undefined
  • Phone numbers

There are cases where the transaction ID appears in the URL in a key=value format after a question mark. For example, if the URL is https://yourshop.com/success?order_id=54321 , then order_id is the variable name and 54321 is the transaction ID. The rest of the URL shouldn’t be used as the transaction ID.


About transaction ID and the "Count" setting

Adding a transaction ID to your event snippet is not the same as changing your “Count” setting to count one conversion per ad click.

By adding a transaction ID, you avoid counting the same conversion twice, such as when someone re-opens a purchase confirmation page and one purchase would be counted as 2 conversions.

When you change your “Count” setting to one, you count only one conversion after an ad click, even if multiple conversions, such as multiple different purchases resulted from the ad click.

So when should you use “Count” versus transaction ID?

  • If you want to track one lead per ad click, change your count setting to “One.”
  • If you want to track every purchase a customer makes after an ad click, but want to make sure you don’t count the same purchase twice, add a transaction ID to your event snippet. Adding a transaction ID is the recommended option for purchases.

Note:

  • Transaction IDs won't be reported in Google Ads.
  • Adding a transaction ID to your snippet will not resolve duplicate view-through conversions.
  • If your website already has a solution for removing duplicate conversions, we recommend adding the transaction ID as an additional tool to ensure your conversion data is as accurate as possible.
  • If you use Google Tag Manager, you can use transaction IDs. Make sure to enter the transaction ID as a variable , not a static string.

Related links

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Google apps
Main menu
14524828898835130838
true
Search Help Center
true
true
true
true
true
true
73067
false
false
true
true
false
Create a Mobile Website
View Site in Mobile | Classic
Share by: