Stape
Search
Try for free

Duplicate Transaction Checker variable for Google Tag Manager server container

Updated
Sep 10, 2024
Published
Sep 5, 2024

Duplicate Transaction Checker is a custom template, designed to help prevent duplicate transactions from being tracked in conversion tracking setups, such as Google Ads or Analytics

This situation often arises when:

  • users refresh the confirmation page after making a purchase.
  • the same transaction ID is sent multiple times due to delays or retries in the transaction process.

Without this mechanism, multiple conversions for the same transaction would lead to inaccurate reporting, inflated conversion numbers, and incorrect revenue data.

The initial development of this template was done by Lars Friis, and it is now maintained by Stape.

How to set up Duplicate Transaction Checker variable

2. Download Duplicate Transaction Checker from GitHub or add it from Template Gallery. Import the variable to server Google Tag Manager by clicking Templates → New Variable Template → Click three dots in the top right corner → Click import → Add template that you’ve recently downloaded → Click Save.

Duplicate Transaction Checker variable

How it works

Duplicate Transaction Checker variable

Transaction ID - type value that will be used as transaction ID. It will act as a unique identifier for each purchase. When the same transaction ID is found multiple times, it flags that as a duplicate.

I use Stape.io - if enabled (as shown in the screenshot), Stape is used to store transaction data, helping ensure transaction records persist and are correctly checked across sessions or events. If Stape is not used, Firebase is required as an alternative for storing transaction data.

Log Settings - this section offers options to log the results:

  • Do Not Log: no logs will be generated.
  • Log to Console During Debug and Preview: this logs information only during testing, providing useful feedback when setting up or debugging tags.
  • Always Log to Console: this logs each time a check occurs, even in production.

How to use it

The variable will check the transaction ID that comes in the event data and compare it with the transaction ID that was previously recorded in the store. 

If the transaction ID is unique - the variable will return ‘false’, if a duplicate transaction ID is found - the result will be ‘true’.

Then you can use this verification in the triggers you need.

Duplicate Transaction Checker variable for Google Tag Manager server container

How to use Stape Store instead of Firebase

1. Enable "I use Stape.io" in the variable. You don't need to configure Firebase in this case.

2. Go to your Stape account → open the container and choose Store. The order IDs will be stored here.

Stape store

Advantages over Firebase:

  • Simplified Setup: you avoid needing to create and manage a Firebase project.
  • Built-In Functionality: Stape is specifically optimized for server-side GTM, so it's more tailored for these types of operations.
  • No External Dependencies: by using Stape's solution, you keep everything integrated within the same platform, reducing complexity.

Note: If you want to integrate the Duplicate Transaction Checker with the Stape Store, you’ll need to set up your server-side tagging environment with Stape to handle transaction storage and retrieval in the background.

Conclusion

Duplicate Transaction Checker variable offers a crucial solution for maintaining the accuracy of conversion tracking data. By preventing duplicate transactions from being recorded, this tool helps ensure that your conversion metrics remain reliable, preventing inflated numbers and inaccurate revenue reporting.

Don’t hesitate to contact Stape support: we will answer your questions and help resolve any issues you might be experiencing on Stape as quickly as possible.

Tagged with:gtm server

Try Stape for all things server-sideright now!