Question about the Checkout Object Lifecycle

Highlighted
Tourist
3 0 2

Hi,

 

I am building a Shopify App to help with behavioral analytics and am trying to add Checkout Started and Checkout Step Viewed events. I was planning on using checkout/create and checkout/update webhooks, but I'm concerned they don't fire when I would want. I can't find any detailed documentation on the checkout lifecycle, so I'm hoping the community can help shed some light.

 

When is a new checkout object created? When is one deleted?

Is the checkout/updated webhook only fired when new data is entered into the checkout forms? ie: if a user is navigating through a checkout flow they have previously partially completed, will this webhook not fire for those previously completed steps?

 

Thanks for the help!

1 Like
Highlighted
New Member
2 0 0

Hi Justin ! Did you find a solution for you Checkout Step issue ? I'm also trying to achieve the same thing, to avoid using/paying a third party App. I was asking myself the same questions regarding checkout/create  | checkout/update. My idea was to do some comparison on shipping address being empty or not. Let me know if you find answers !

0 Likes
Highlighted
Excursionist
30 3 3

Hi @justinc474 , @GuillaumeBrs 

Here's the Shopify's available webhooks:

https://help.shopify.com/en/manual/sell-online/notifications/webhooks#create-webhooks

 

When do you want to get notified in the checkout process?

If you want to fire an event when a user clicks the checkout button, then you should add an ajax call to your API on the Shopify front-end.

You can do this by modifying theme files.

 

Are you looking for a new store or have a problem? Let me know!
0 Likes
Highlighted
New Member
2 0 0

Thanks Flexkit. 

I want to be notified for every Checkout Steps, to be able to track our Checkout Funnel (ex: Step 1 - information / Step 2 - Shipping / Step 3 - Payment) 

I was considering doing it with checkouts/update webhook. But I'm conscious this might not be a trivial task !

0 Likes
Highlighted
Excursionist
30 3 3

@GuillaumeBrs I think you can register a webook on checkouts/update and then check on every step using this REST API - /admin/api/2020-04/checkouts/{token}.json

 

When you get a response from the webhook, then you can immediately get the status of checkout. Please read Retrieve a processing checkout part of checkout documentation from herehttps://shopify.dev/docs/admin-api/rest/reference/sales-channels/checkout?api[version]=2020-04

 

Are you looking for a new store or have a problem? Let me know!
1 Like
Highlighted
Tourist
3 0 2

@flexkit as far as I can tell the REST API returns the same payload at the checkout/update webhook, which has no information to denote which step the user was on. Also, webhooks can be delayed by 3-5 minutes and have no guarantee of being delivered in order, so by the time you check the REST API they may be on another step.

 

@GuillaumeBrs the way I have solved this is to cache the Shipping Address (shipping_address), Payment Info (billing_address), and Shipping Method (shipping_lines). Then I have code which compares them and fires the correct event based on which has changed. There are some edge cases to this (ie: for existing customers they would have their Shipping Address pre-filled so either you fire the event off checkout/create, knowing they have yet to be on that page, or you do not fire it). If you really want to know the page, I'd try adding JS to your checkout flow.

 

@flexkit last point on the checkout/create - I know where the webhook documentation is but it is not helpful. The definition is: a webhook will be sent every time a checkout is created. However there is no description of when a checkout is created. The system could behave is a myriad of ways so this is not a very helpful description if an app developer wants to do something deterministic with this webhook.

1 Like