The Transaction ID Reader custom variable template is a variable template for Google Tag Manager’s community template gallery. It is designed to work together with the Transaction ID Logger tag template.

Resource
Gallery entry
GitHub repo

Description

When you create a variable with this template, you need to configure two settings.

First, you need to provide the Transaction ID that will be checked against the stored IDs. Typically this would be a Data Layer Variable that returns the ID from an Enhanced Ecommerce object or from a GA4 dataLayer.

When the variable is resolved, it looks for a browser cookie and/or a localStorage entry named __tid_gtm. This is created by the Transaction ID Logger tag template.

The entry contains an array of all the transaction IDs recorded by the Transaction ID Logger tag.

The variable checks if the Transaction ID the user provided is found within this array, and if a match is made, it returns true. If no match is made, the variable returns false.

Instead of a boolean return value, you can also choose to have the variable return the full array of stored Transaction IDs, in case you want to process this information for some other reason.

You can use the variable to conditionally block purchase tags from firing again if the user returns to the purchase page after the purchase has already been registered.

This is an alternative solution to my Universal Analytics’ customTask deduper, as platforms like GA4 and Facebook do not support customTask.

Release notes

Date Changeset
11 December 2020 Initial release.