Solved

Cannot track started checkout in Woocommerce

  • 23 June 2021
  • 8 replies
  • 938 views

Badge +2

Hi!
I've done the Woocommerce integration, all the events are correctly uploaded in Klaviyo exept the Started Checkout.
 

I tried to reinstall the plug in, but nothing worked.
I also did some tests myself following the directions found on this community but they don't seem to work.

Any advice?

icon

Best answer by David To 23 June 2021, 18:25

View original

8 replies

Userlevel 7
Badge +60

Hello @Matteo,

Thanks for being a member of the Klaviyo Community!

Glad to hear you tried troubleshooting by updating and reinstall the plugin first!

Some other common reasons why despite having an up-to-date plugin version, the started checkout metric is not being recorded could be due to not being cookied when testing or if you are using a single step checkout page. 

When testing, I would recommend using a private or incognito browser and cookieing your browser by following the steps below:

  1. Navigate to your website
  2. Add the following to the end of your store URL, replacing example@gmail.com with your email address:
    ?utm_email=example@gmail.com
  3. After you reload the page, search in Klaviyo for your email address

Using this method would ensure that the browser you are using is cookied and being tracked by Klaviyo. You can learn more about how cookies and Klaviyo’s web tracking works from the Guide to Klaviyo Web Tracking article. 

Another possibility as to why your started checkout metric is not trigger is if you were using a single step checkout page. A started checkout metric is created when:

  • A customer logs into their account, adds something to their cart, and then views the checkout page
  • A customer adds something to their cart, views the checkout page, and enters a billing address.

Because a single page checkout process would allow users to enter their contact information, shipping option, and billing information, this would bypass Klaviyo’s ability in collecting the initial information required for the stated checkout metric and only record the placed order metric. Typically, a started checkout metric is recorded when a contact adds an item to their cart, goes to the checkout page and enters their contact information including their email address and proceed to the next page for shipping options. This process of moving from the checkout page to the next shipping option page submits the contact information and triggers the started checkout metric. As such, we would recommend using a multi-step checkout process as opposed to a single page checkout process to properly trigger the started checkout metric.

Lastly, a less common cause of this would be if you were using the Woocommerce Blocks plugin. At this time the Woocommerce Blocks plugin is not supported by Klaviyo as it does not pass the required information in order for Klaviyo to trigger the started checkout metric. You can read more about this in a similar Community thread below:

I hope this helps!

David

 

Badge +2

So this means if you do not have a multi-step checkout and/or going to the shipping credentials page is not done through a submit (but through a HREF or whatever), the Klaviyo event does not trigger?

It makes sense if this trigger is activated by a Wordpress hook, but this prevents people from ever customizing their checkout (and even using “block builders” like Gutenberg?). 

Is it possible to trigger by a JS onClick or something like that?

Userlevel 7
Badge +60

Hey @moowy,

That’s correct! As part of the native integration between Klaviyo and WooCommerce, the Started Checkout event is triggered by a webhook as part of the Klaviyo plugin.

For customers who wish to use a more customized checkout process, you certainly can do so! Instead of leverage the default WooCommerce Started Checkout event, this would require you to custom code your own custom Started Checkout event to trigger at your desire point such as via a JS onClick action. 

You can find out more about custom coding your own events and using Klaviyo’s API from the following Help Center articles:

Have a great day!

David

Badge +2

Thanks, David, but instead of pointing us to the generic API docs, could you point us to where it tells us how to add the metric “Started Checkout” to a profile?

Because I have browsed all API docs and could not find an answer to that specific question…..

 

CHeers!

Userlevel 7
Badge +60

Hey @moowy,

You can find an example track request for a Started Checkout event from the Started Checkout subsection of the Integrate a Standard Ecommerce Platform Help Center article previous mentioned. In addition, if you wanted to test your track requests prior to setting it up within your backend, you can manually trigger the Started Checkout event for a profile by making test calls while using this track request as instructed in the Make Your First Call subsection of the Getting Started with Klaviyo APIs Help Center article. 

Because this would be a custom setup, you can customize how and when this custom Started Checkout event is fired and recorded by your contacts. I would suggest working with a developer or finding a Klaviyo partner who can further assist you on this developmental work to custom code your desired functionality of the Started Checkout event. 

David

 

Badge +2

For anyone stumbling on to here looking to apply the  “Started Checkout” metric: I hope the (rather crude!) code below helps you get started. Put it in your functions.php or footer.php...
 

<?php
if($_GET["step"]=="shipping")
{ //tell WP to load this code conditional, so IF there is sth in the querystring OR if page has a certain template OR is_home() etc.

if(isset(wp_get_current_user()->user_login) && count(WC()->cart->get_cart())>0)
{ //check if the user is logged in AND if there is stuff in his cart...
$cart = WC()->cart;
$event_data = wck_build_cart_data( $cart );
if ( empty($event_data['$extra']['Items']) ) { return; }
$event_data['$service'] = 'woocommerce';
unset($event_data['Tags']);
unset($event_data['Quantity']);
$email = wp_get_current_user()->user_email;
$fullname = explode(" ",wp_get_current_user()->display_name); //reading name from session and not through Javascript!

$firstname = $fullname[0];
array_shift($fullname);
$lastname = implode(" ", $fullname);

$params = '{"token":"XXXXXXXXX","event": "Started Checkout","customer_properties":{"$email":"'.$email.'","$first_name":"'.$firstname.'","$last_name":"'.$lastname.'","language":"'.strtoupper(ICL_LANGUAGE_CODE).'"},"properties":'.json_encode($event_data).'}';
$options = array(
'method' => 'POST',
'body' => "data=".urlencode($params),
'headers' => array(
'Accept: text/html',
'Content-Type' => 'application/x-www-form-urlencoded',
),
'timeout' => 30,
'redirection' => 10,
'blocking' => true,
'httpversion' => '1.0',
'sslverify' => false,
'data_format' => 'body',
);

$response = wp_remote_post('https://a.klaviyo.com/api/track', $options );

//writing out response is only for testing!
if ( is_wp_error( $response ) )
{
//echo $response->get_error_message();
}
else
{
//print_r( $response );
}
}
}
?>

 

Userlevel 7
Badge +60

Hey @moowy,

Thanks for sharing your findings with the Klaviyo Community! I’m sure this will help other Community members in the future!

Appreciate you for being a part of the Klaviyo Community!

David

Badge +1

Hi moowy,

Does this code for the “Started Checkout” metric work for Single Page Checkouts? Or does it have to be a Multi page checkout?

 

Many thanks.

Reply