Google Analytics eCommerce extension is firing on page reload inflating transactions quantities.

Bronze Contributor
Bronze Contributor

Tealium is sending multiple transaction hits to Google Analytics, inflating ecommerce transaction quantities. How do I set an exception to the extension so if if the pageload is the result of a page reload/refresh, to not fire the tag?

9 REPLIES 9

Google Analytics eCommerce extension is firing on page reload inflating transactions quantities.

Tealium Expert
Tealium Expert

@anourani -  is  the  transaction number the  same each  time? GA should  be deduping  on unique  transaction numbers.  

 

Beyond  that, it  should  be possible  to  set a cookie the first time the tag fires  to  use as a  condition  to be checked the next  time the tag might be triggered. Others may have  some ideas  and chime in as  well.  You  might   also research  why  the page is  being  refreshed so often.  Good luck, and look forward  to  your updates  how you solved so others   can  benefit from your experience.

Tealium Expert

Google Analytics eCommerce extension is firing on page reload inflating transactions quantities.

Gold Contributor
Gold Contributor

Have you resolved this issue using Tealium? I see this is an issue that has some documented solutions in Google Tag Manager and also using server-side measurement protocol. But, if you've managed to solve this in TiQ, it would be very appreciated if you would share the solution.

Google Analytics eCommerce extension is firing on page reload inflating transactions quantities.

Tealium Expert
Tealium Expert

As per @mitchellt previous post. you can drop a cookie and set a condition against this to prevent duplicate fires. 

Research your Experience | Improve and Evolve | Leave no one behind
- Don't forget to mark a solution as accepted if it hits the mark -

Google Analytics eCommerce extension is firing on page reload inflating transactions quantities.

Gold Contributor
Gold Contributor

@GavinAttard , after several attempts to solve this in our application and with Tealium, I believe I need some help here. I see quite a few posts on the internet on how to do this with Google Tag Manager, using a callback function of the GA tag. But I haven't been able to successfully translate those into how to do it with Tealium. 

I do understand that the basic steps (copied from a post on Google Tag Manager method) are: 

  1. Create a user defined variable to extract the transaction id from the dataLayer
  2. Create a user defined variable to save the transaction id in a 1st party cookie
  3. Create a user defined variable to retrieve the contents of the 1st party cookie
  4. Create a user defined variable to check if the current transaction is already stored
  5. Update the event trigger [not sure of TiQ equivalent, since it is simply based on presence of a transaction ID in the e-commerce extension) for the GA Enhanced Ecommerce Purchase tag to stop it triggering if the current transaction id is in the cookie
  6. Update the GA Enhanced Ecommerce Purchase tag to ensure the transaction id is saved to the cookie.

Would you be able to outline specifically how to make this work with the standard Tealium GA tag (we are using the "legacy" analytics.js tag).

Google Analytics eCommerce extension is firing on page reload inflating transactions quantities.

Tealium Expert
Tealium Expert

Hi @Krasner 

Create a datalayer property of type cookie - call it 'transaction_made' or any other appropriate name. 

Using the persist extention drop a cookie and populate it with the data layer property that holds your order id. set expiry to what you think is most appropriate. 

Place this at the boittom of your extention list and scope to after tags. 

You can place a condition on it to check if the cookie already exists, and if the value it holds is the same as the value in the order_id datalayer property. If it exists and is the same, then no need to drop again. 

Create a data layer property called is_order. 

Create a Set data value extention, scope it to before tags and place appropratly in extention list. This extention shuold set the is_order to true if the cookie does not exist, or the cookie exists and the value it holds is not the same as the value in the order_id datalayer property

Finally map the is_order to the GA order action to trigger on true.

I think... that ought to do it. 

kr


Gavin

 

Research your Experience | Improve and Evolve | Leave no one behind
- Don't forget to mark a solution as accepted if it hits the mark -

Google Analytics eCommerce extension is firing on page reload inflating transactions quantities.

Gold Contributor
Gold Contributor

@GavinAttard Thank you very much for the detailed instructions. These are very helpful. I do have one follow-up about where you wrote "Finally map the is_order to the GA order action to trigger on true".

We are using Tealium's standard GA tag. And in this tag, there is logic built into its template to create the order action based on the presence of a value in the order_id field. So, we don't have any explicit extension or tag to fire the order event, but rather the Tealium tag does it by itself, based on whether there is an order_id or not. 

I've pasted the relevant section fro the standard Tealium GA tag below, whcih controls whether the order action occurs. If I am following you, then what we would need to do is to customize this tag, by adding another IF, so that in addition to the presence of the u.data.order_id field, it also requires that is_order = true. Is that correct? Or is there a way to do this without customizing the tag template?

Here is the relevant section from the standard tag template:

//ENH: ORDER start
else if (u.data.order_id) {
if (u.data.order_id instanceof Array && u.data.order_id.length > 0) {
u.data.order_id = u.data.order_id[0];
}
u.addproduct("product_purchase", u.data.product_id.length, false);
g = {};
g.id = u.data.order_id;
g.affiliation = (u.data.affiliation ? u.data.affiliation : u.data.order_store);
g.revenue = (u.data.revenue ? u.data.revenue : u.data.order_total);
g.shipping = (u.data.shipping ? u.data.shipping : u.data.order_shipping);
g.tax = (u.data.tax ? u.data.tax : u.data.order_tax);
g.coupon = (u.data.coupon ? u.data.coupon : u.data.order_coupon_code);
u.setHitData(g, "enhecom_events", "purchase");
u.all('ec:setAction', 'purchase', g);
// ENH: ORDER end

Google Analytics eCommerce extension is firing on page reload inflating transactions quantities.

Tealium Expert
Tealium Expert

Hi @Krasner 

Indeed the answer is right there in your reply. 

Instead of populating is_order with a boolean value, get it to populate with the order id if the conditions are met. 

Then map the is_order to the transaction id in the GA tag. 

If is_order has a value, then it will fire the order, if left unpopulated/undefined etc... then it won't fire. 

Research your Experience | Improve and Evolve | Leave no one behind
- Don't forget to mark a solution as accepted if it hits the mark -

Google Analytics eCommerce extension is firing on page reload inflating transactions quantities.

Gold Contributor
Gold Contributor

@GavinAttard Thanks. So, now the part of this where I'm having difficulty is setting a condition on the extension to check whether one variable equals another variable. I can choose  avariable as the first part of a condition, but then after the expression like "equals" or "does not equal", it does not let me choose another variable. Only to enter a text value. How does one compare two variables in an extension condition?

I'm trying to implement the condition in the "set data values" extension" to only set the is_order when the current order ID does not equal the one in the cookie. So, I need to compare two variables in this case.

Google Analytics eCommerce extension is firing on page reload inflating transactions quantities.

Tealium Expert
Tealium Expert

@Krasner 

Ah, of course.. doh... you will need ot use a custom javascript extention

somethign along the lines of 

if(b["cp.cookiename"] && b["cp.cookiename"] == b.orderid) {
    b.is_order = b.orderid;
}

set the extention condition to run only on the order confirmation page. 

 

 

Research your Experience | Improve and Evolve | Leave no one behind
- Don't forget to mark a solution as accepted if it hits the mark -
Public