PREVENT DUPLICATE TRANSACTIONS IN GOOGLE ANALYTICS how to fix in tealium

Silver Contributor
Silver Contributor
  • Some orders have 3-4 times of the revenue captured in GA
  • Same order captured multiple times in GA
1 REPLY 1

PREVENT DUPLICATE TRANSACTIONS IN GOOGLE ANALYTICS how to fix in tealium

Gold Contributor
Gold Contributor

Here is what we did, whcih seems to have resolved the issue:

  1. We created a data layer variable called "unique_order_id"
  2. We created a cookie variable called "previous_order_id"
  3. We created an extension to persist any incoming value in "purchase_id" (our existing variable for order ID) into the cookie, whenever it is populated and on the order confirmation page.
  4. We created another extension, with a condition that the already existing variable "purchase_id" is populated, to set the value of the unique_order_id to an empty string if it's the same as the cookied value of "previous_order_id", otherwise it sets it to the value of the "purchase_id". See code example below
  5. We changed the Ecommerce extension mapping to map only the "unique_order_id" to the order ID, which is what is subsequently mapped into the GA tag and whcih triggers the purchase event

Here is the example of code from the extension to set the unique_order_id:

// Set unique order id to empty string if order is same as previous cookied order id
if (b.purchase_id){
    b.unique_order_id = b.purchase_id;
    if(b.purchase_id === b['cp.previous_order_id']){
        b.unique_order_id = "";
    } else {
        b.unique_order_id = b.purchase_id;
    }
}
Public