Analytics
1.7K members online now
1.7K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

[Bug] Safari on iPhone & Duplicate Transactions

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I am not sure anyone from Google will see this, or if this has been reported before. But I am getting duplicate transactions in Enhanced Ecommerce, and have tracked it down to the Safari browser on iPhone.

However, I am pretty sure it's some pre-caching that the Safari browser does to make pages load quickly. Hopefully we're not in a situation where Safari says Analytics needs to account for this, and Analytics says this is a Safari issue. Or someone has an idea how to fix this.

Basics of my Setup
Google Tag Manager: GA tag with a track type of event. The trigger that fires it is a custom purchase event I push.
Woocommerce: Built on top of Wordpress, I hook into the "woocommerce_thankyou" action. This fires when the thank you page is loaded after an order is successful. I have a simple check in here that says do not push any tracking variables to the front end if the page has already loaded. Below is an example of the actual event and data I am making available to the front end. It is only echo'd the first time:

 

$dataLayer = array(
	        'event' => 'purchase',
	        'ecommerce' => array(
	            'purchase' => array(
	                'actionField' => array(
	                    'id' => $orderId,
	                    'affiliation' => 'Online Store',
	                    'revenue' => $order->get_total(),
	                    'tax' => $order->get_total_tax(),
	                    'shipping' => $order->get_total_shipping(),
	                ),
	                'products' => $products
	            )
	        )
	    );


When looking at our Analytics in production over the last 6 months, I took inventory on every single order reported more than once. The one thing that was common among every single of these orders was they were all on iPhones, and they were all using the Safari browser.

I have session recording on the site, and watched every loading of these thank you pages. And every single one demonstrated the same behavior:

Normal shopping behavior. Picked their products, went cart, checkout, and then got their receipt. Session ends
(Hours or days later) The thank you page refreshes, direct load of the page, no other pages in the recorded session.
What I think is happening is the user leaves the thank you page receipt open on their phone. The iPhone/Safari is caching EVERYTHING it received in order for any refreshes of the page to happen quickly for better experience for the user.

However, it's messing up my numbers.

I tried using the eventCallback so once the purchase event was pushed, it was cleared locally. So there was no record of it in the user's browser, and would not be returned from the web server. That didn't work because it was clearing the dataLayer before the event made it to the data model.

 

jQuery(document).ready(function() {

	//order received object available from server
	if (typeof ee_order !== 'undefined' ) {

		//check all data layer objects to see if it already has ecommerce purchase object
		var found = false;
		dataLayer.forEach(function(item) {
			for (var prop in item) {
				//console.log(item[prop]);
				if (prop === 'event' && item[prop] === 'purchase') {
					found = true;
					break;
				}
			}
		});

		//add eventcallback
		//Not using not b/c it was clearing dataLayer before event made it to data model
		//ee_order.eventCallback = clearOrderData();
		//push to data layer
		if (!found) {
			dataLayer.push(ee_order);
		}
	}
});


I also tried removing it from the dataLayer array where my "found = true" statement is, but it was still being pushed to the GTM data model before it was cleared out.

Has anyone else experienced this? Is this something Google can fix, or has a good workaround for it?

Re: [Bug] Safari on iPhone & Duplicate Transactions

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭
Hi Nathan,

Did you ever find a resolution to this? We are experiencing the same issue and I cannot find a way around it.

Kind Regards,
Nathan

Re: [Bug] Safari on iPhone & Duplicate Transactions

[ Edited ]
Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

I found I had to put checks in place server side and client side; server side wasn't enough. Using a cookie client side was the only solution that seems consistent so far. I actually was just documenting this for myself earlier this week. See this post on duplicate transactions

Re: [Bug] Safari on iPhone

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
Hi Nathan,

Thanks for the info!
We had implemented the server side stuff much earlier. We tried the cookie
a fortnight ago and that hasn't resolved it either.

Re: [Bug] Safari on iPhone

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Yeah, while it's working now, I am not confident it's a long term solution. Maybe I've gotten lucky that I haven't had any duplicates lately. Wish I could get Google's attention on this one, but so far no success.

[Bug] Safari on iPhone & Duplicate Transactions

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Hi Everyone,

 

I am experiencing the same issue. Do anyone found any solution till yet? I have both server side and cookies based solution in place. Still facing the issue.

 

Regards

Nameet Jain

[Bug] Safari on iPhone & Duplicate Transactions

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭

anyone figure this out yet? I setup a cookie function and some server side settings but I am still getting a lot of dupe transactions all from mobile safari. I can't replicate the issue either with test orders