AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
3.7K members online now
3.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

Google Analytics is showing failed transactions as eCommerce Transcarions

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

We use woocommerce and Google analytics to track eCommerce purchases. Google analytics is taking failed payment as the eCommerce conversion. Could anyone help me with this?.

 

Thanks.

1 Expert replyverified_user

Re: Google Analytics is showing failed transactions as eCommerce Transcarions

Top Contributor
# 2
Top Contributor
Hi,

How did you set up ecommerce tracking with Woocommerce?

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Google Analytics is showing failed transactions as eCommerce Transcarions

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thank you for the reply. Yes, I have done that. Tracking sales and all
working fine. But the only issue is, if payment is failed in the payment
gateway, still Google Analytics shows it as completed transaction.
--
Bharathidasan Moorthi, Augrav.com

Re: Google Analytics is showing failed transactions as eCommerce Transcarions

Top Contributor
# 4
Top Contributor
Hi,

I meant how did you set up the tracking on the site, using which plugin?

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Google Analytics is showing failed transactions as eCommerce Transcarions

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

You should use the woocommerce_thankyou action. That is only loaded on successful orders. When using that function, you can push your order info to the front for pushing to the dataLayer. Something like the following should get you started.

Please note, this is an event based solution (event = purchase in my array below). And I also use tag manager to listen for this event. Regardless, however you make the data available for Enhanced Ecommerce, the best place to do it is in the "woocommerce_thankyou" action as that is fired on successful orders only.

public function purchaseMade( $orderId )
{
   //Check to see if we've tracked this order before
   $orderTracked = get_post_meta($orderId, 'gtmOrderTracked', true);

   //Don't do any of this conversion stuff now
   if ($orderTracked) {
      return;
   }
   // Lets grab the order
   $order = new WC_Order( $orderId );

   //Add the order ID as a custom field so we don't push conversion data that's already been logged
   update_post_meta($orderId, 'gtmOrderTracked', $orderId);

   ...
   ...
   ...
   // prep your data before you get here, and set your variables however you like
   $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
	            )
	        )
	    );
    
      // Then here you can echo it to the front end, make it available to JavaScript, whatever you want to get it to Google Analytics.