Solved

Attributing user actions to orders via Shopify app

arsakar
Shopify Partner
12 1 6

I have a Shopify app that adds a visual widget to Shopify stores. What I want to do is to find out if a user interacted with our widget before purchasing an order. Since this is a Shopify app, I am facing difficulty in figuring out a generalised solution for the same.

 

Here is where we have got to so far:

 

1. For every user that lands on the store, we assign them a unique guid. Whenever this user takes an action on the widget, we record the action and attribute it to this guid. When a user adds an item to the cart, we intercept the add (or cart) calls and add a custom property to it attributing this guid to that item in cart. When this order gets placed, we listen to the webhook and find this guid available in the order's line items.

This method works well for all cases of adding products to cart. Where it fails though is on those 'Buy Now' buttons which directly takes a user to the checkout, where we do not get an add or cart call to intercept. Also, a bunch of custom properties in the order side of the admin page often ends up being annoying for the store owner and sometimes breaks some integrations with some apps.

 

2. We put the a tracking script on the thank you page. This solves the Buy Now problem (since all completed orders reach the thank you page, including the buy now ones). But the trouble here is that it have a major leak issue. If users quickly close the Thank You page post payment, the event never has the time to fire. This happens a lot (even with GA). Also, this gives us no way to attribute users to abandoned carts.

 

3. Intercepting the cart call gives us the user's cart token. We can store the association between the user's guid and the cart token in our backend. When the order webhook fires, we can check the cart token and use that to attribute to the user. While this solves the problem in point 1 of the storeowner not having to deal with those lines of custom properties, it still doesn't solve the 'Buy Now' button problem because we can't figure out any way to get the checkout token of a user from the frontend.

 

Any one of the following ways would help us overcome this issue but I can't figure out a way to do so:

 

1. Getting a user's checkout id before the checkout page is loaded (since we can't insert any scripts into the checkout page except for Plus stores).

2. Intercepting a redirect to a checkout page, getting the items that are supposed to be checked out, adding custom properties to it so when the order webhook arrives, we can do the attribution.

 

Kind of stuck here. Would appreciate any help regarding the same!

 

TLDR: Trying to find a generic way to attribute a custom user action on the store to an order placed by the same user via a Shopify app

Building video shopping experiences
Accepted Solution (1)
arsakar
Shopify Partner
12 1 6

This is an accepted solution.

The hacks around this were very difficult. But now that web pixels have been introduced, this is not a problem anymore. https://shopify.dev/apps/marketing/pixels

Building video shopping experiences

View solution in original post

Replies 2 (2)

jmattiace
Shopify Partner
9 0 2

hey @arsakar , wondering if you ever found a solution to this? I'm running into the same exact issue at the moment.

arsakar
Shopify Partner
12 1 6

This is an accepted solution.

The hacks around this were very difficult. But now that web pixels have been introduced, this is not a problem anymore. https://shopify.dev/apps/marketing/pixels

Building video shopping experiences