Solved

Can I create an email button that recreates an abandon cart and autofills a discount code?

  • 4 November 2021
  • 3 replies
  • 205 views

Badge +2

Hi all, 

 

I am setting up my abandoned cart sequence, but I’m having trouble. 

 

I am offering a discount in Email 2, and I would like for the button (that customer clicks to go back to their cart), to automatically take them to checkout WITH the discount code automatically applied. 

 

I have used this link in the button link:

 

https://www.mysite.com/STOREFRONT_ID/checkouts/{{ event.extra.token }}?discount={% coupon_code 'NAME_OF_YOUR_COUPON' %}

 

However when I preview the Email in Kaviyo, and click the button, it links me my site and says ‘404 page not found’. 

 

It does link me to the site, but that message comes up as a page on my store. Instead of checkout etc.

 

Is that normal?

 

Is it because I am not the customer that added that product to the cart so it can’t link me to the checkout?

 

I just want to make sure before I make these Emails live. 

 

Any help would be appreciated. Thanks. 

icon

Best answer by Taylor Tarpley 4 November 2021, 15:17

View original

3 replies

Userlevel 7
Badge +60

Hi@Islandboy100

 

Welcome to the Community, thanks for sharing your question with us! I love this idea!

 

What you want to do is very possible, however, the error message is displaying because you need to reconfigure the code in the URL. You were so very close! You will need to change the ‘?’ in your code to a ‘&’ and it should do the trick! I’d also recommend pasting this code into the email without any extra formatting by either manually typing out the syntax or pasting the code into the template editor by pressing ctrl+v+shift. This will help ensure correct functionality.

 

https://www.mysite.com/STOREFRONT_ID/checkouts/{{ event.extra.token }}&discount={% coupon_code 'NAME_OF_YOUR_COUPON' %}

 

Thanks for sharing your question with the Community! 

-Taylor

Badge +2

Hi@Islandboy100

 

Welcome to the Community, thanks for sharing your question with us! I love this idea!

 

What you want to do is very possible, however, the error message is displaying because you need to reconfigure the code in the URL. You were so very close! You will need to change the ‘?’ in your code to a ‘&’ and it should do the trick! I’d also recommend pasting this code into the email without any extra formatting by either manually typing out the syntax or pasting the code into the template editor by pressing ctrl+v+shift. This will help ensure correct functionality.

 

https://www.mysite.com/STOREFRONT_ID/checkouts/{{ event.extra.token }}&discount={% coupon_code 'NAME_OF_YOUR_COUPON' %}

 

Thanks for sharing your question with the Community! 

-Taylor

 

 

Thanks very much Taylor! I really appreciate your reply. 

 

I typed in the syntax manually and as a result when I preview the email, and click the button to ‘go to checkout with discount applied’ 

 

This is what comes up:

 

 

Is this normal as I am just previewing it?

 

(I’d like to remind you that I’m doing this in the abandoned cart flow and not abandoned checkout flow)

 

I’m wondering if I’ve gotten it right now? and that it’s just showing me this because I was not the actual customer in the event url etc.

 

If you could point me in the right direction, or let me know If I’ve done it correctly now, or even if this is not possible in the abandoned cart flow. 

 

Please let me know. 

 

Thanks a lot,

 

Reards

Userlevel 7
Badge +60

Hi @Islandboy100,

 

Thanks for that additional information, that was very helpful to finding a solution here!

 

Klaviyo uses the term ‘Abandon Cart’ synonymously with an ‘Abandon Checkout’ sequence. I think this is important to know as you might search for Help Center documentation in the future and to explain why this code didn’t work initially. The code would have worked if it was as a true, Klaviyo ‘Abandon Cart’ sequence because the code is designed to take you back to a previous checkout and rebuild a customer’s cart as it was, with the discount applied. The code did not work because in your instance there was no checkout to be brought back to.

 

However, we could still accomplish what you’re looking for by adding a link to your email's button that would apply a discount to the web browser when it is reopened. This way, when they do head to checkout for the first time, the code will be appear as it was automatically applied when they clicked through the link. 

 

You can use this code for a static coupon code: 

mysite.com/?discount=your_code 

 

And this for a dynamic coupon code: 

mysite.com/discount/{% coupon_code 'your_code' %}

 

Thanks for being a part of the Community! 

Reply