Block Duplicate Transactions – GTM Template (Server)

This Variable for Google Tag Manager Server-side (SGTM) makes it possible to Block Duplicate Ecommerce Transactions from being sent to your analytics/marketing tools.

How the Variable Works

Incoming transaction_id will be checked against earlier transaction id’s from the user stored in a cookie. If a match is found, the Variable will return true (duplicate is true). We can then block transactions from being sent based on this output.

If no match is found the Variable will return false (duplicate is false), and incoming transaction_id will be added to the cookie. Transaction ID’s will be stored in the cookie as an array (e.g. [“123″,”456”]).

This Template is available in the Google Tag Manager Template Gallery.

Full documentation of the Template can be found on Github.


  • Read Transaction ID from Event Data (transaction_id) or Variable
  • Only set Cookie if Consent is given
  • Hash transaction_id as SHA-256
  • Limit Cookie Size
  • Choose your own Cookie Name
  • Select Cookie Expiration in Days
  • Other Cookie Settings
    • Set Cookie Domain as auto
    • Set SameSite attribute
    • Set Cookie as HttpOnly

Image of the Template

Block Duplicate Transactions – GTM Template (Server)