Skip to main content
Solved

Klaviyo breaking URL with multiple parameters


Forum|alt.badge.img+1

Hi there,

 

I'm building a custom URL within an email template to be sent through Klaviyo, that takes a customer directly to a pre-filled checkout. The URL contains multiple parameters and here's an example of what it looks like:

 

https://gustavo-fine-guitars.myshopify.com/discount/GR13JsCWCTgQrOgiuV-TRXB_/?redirect=/cart/add?items%5B%5D%5Bid%5D=39879309459534%26items%5B%5D%5Bquantity%5D=1%26items%5B%5D%5Bselling_plan%5D=574554190%26return_to=/checkout

 

In case you want to test it, my storefront password is 'abc123'.

 

While this URL works fine when you try to load it directly in the browser, if it's sent as a link through an email, Klaviyo breaks it. I did some research and found this topic that suggests disabling the Email-to-website Tracking setting. That works, however, that may be a feature that is actually used by the merchant, so disabling it wouldn't be a possibility. Is there a way to prevent Klaviyo from breaking the URL, while keeping Email-to-website Tracking enabled?

 

Best answer by Taylor Tarpley

Hi @GustavoGovalo

 

Thanks for that clarification! 

 

While the only way to avoid this is to disable Email-to-website Tracking setting, you could choose to setup custom tracking if you really need to accomplish this. You’ll need to disable this setting and include the _KX parameter setting in their URL to create their on pseudo tracking. 

 

However, with all custom coding, it will require time and energy to get this up and working! I would share this with your developer if you have one on your team or  connect with a Klaviyo partner to set this up for you!

 

-Taylor

View original
Did this topic or the replies in the thread help you find an answer to your question?

10 replies

aliriveira
Contributor I
Forum|alt.badge.img+1
  • 2025 Champion
  • 1 reply
  • July 11, 2023

I would bet it has to do with the double “?” in the URL. When Klaviyo is adding the tracking parameters, it’s probably adding it after the first “?” and breaking it. Although, I don’t have a great fix at the moment. 


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 4 replies
  • July 11, 2023

@aliriveira Thanks for the suggestion - I tried replacing "/cart/add?" by "/cart/add%3F" - while the URL loads when trying it directly in the browser, I'm afraid it still fails when it comes through Klaviyo.


Taylor Tarpley
Community Manager
Forum|alt.badge.img+60

Hi @GustavoGovalo 

 

Thanks for hopping in here @aliriveira to help your peer! You’re a rockstar!

 

Unfortunately, @GustavoGovalo as you mentioned, this won’t be possible unless you disable tracking. If that isn’t a possibility for you, do you mind stating your goal of adding these multiple parameters to see if we can find another workaround for you? 

 

-Taylor


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 4 replies
  • July 14, 2023

@Taylor Tarpley Hi, sure, happy to share some extra details. :)

I want to have a button/link in my Klaviyo email that takes the person clicking on it directly to a Shopify checkout with some loaded options - in this case, a subscription product, plus a discount code added.

The way I found of doing it is by loading the URL I mentioned initially, with some parameters added (the product's ID, quantity, selling plan, etc), so the checkout is loaded with everything I need. The URL works fine outside of an email, but when tracking is enabled, Klaviyo seems to replace all the parameters in the URL with the "_kx" parameter, thus breaking the URL and taking me to a 404 page.

 

Is there a way to keep tracking enabled, while still preventing Klaviyo from replacing those parameters by "_kx", perhaps on a specific URL or email template?


Taylor Tarpley
Community Manager
Forum|alt.badge.img+60
  • Community Manager
  • 2148 replies
  • Answer
  • July 25, 2023

Hi @GustavoGovalo

 

Thanks for that clarification! 

 

While the only way to avoid this is to disable Email-to-website Tracking setting, you could choose to setup custom tracking if you really need to accomplish this. You’ll need to disable this setting and include the _KX parameter setting in their URL to create their on pseudo tracking. 

 

However, with all custom coding, it will require time and energy to get this up and working! I would share this with your developer if you have one on your team or  connect with a Klaviyo partner to set this up for you!

 

-Taylor


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 4 replies
  • July 25, 2023

@Taylor Tarpley I see, thanks for the advice!

Do you have any directions on how the _KX parameter can be set up manually for an email? I understand that, with this, the Email-to-website Tracking can be disabled and the _KX parameter can be set up individually for each email template.

Best,

Gustavo


David To
Klaviyo Employee
Forum|alt.badge.img+60
  • Klaviyo Employee
  • 2456 replies
  • July 26, 2023

Hey @GustavoGovalo,

We do not offer any directions on how to setup the _KX parameter due to it’s custom nature. However, I would encourage you to utilize the resources found in our Developer Portal

I would also keep in mind that disabling the Email-to-website Tracking setting mainly impacts:

  • Tracking and triggering the clicked email event
  • User identification (cookie) as they continue to navigate the site (active onsite, viewed product events, etc)

Since you intend to bring user back to a checkout page, in my experience, I don’t see these drawbacks impact too much since:

  • Users are already opening the email and attribution can still be tied back to it
  • Users would be cookied again after filling out the sign-up form. 

David


Omar
Partner - Platinum
Forum|alt.badge.img+46
  • 2025 Champion
  • 494 replies
  • July 26, 2023

@GustavoGovalo have you tried adding the products in another way?

If it's only 1 product:
https://your-store.myshopify.com/cart/[VARIANT-ID]:[QUANTITY]?payment=[PAYMENT-METHOD]&discount=[DISCOUNT-CODE]

 

In case of multiple products add a comma:
https://your-store.myshopify.com/cart/[VARIANT-ID]:[QUANTITY],[VARIANT-ID]:[QUANTITY]?payment=[PAYMENT-METHOD]&discount=[DISCOUNT-CODE]

I think this is another simpler way to accomplish the samen that hopefully doesn't break the url.

 

Omar Lovert // Polaris Growth // Klaviyo Master Platinum Partner

We help with e-commerce growth through CRO, Klaviyo and CVO


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 4 replies
  • July 27, 2023

@Omar I'm afraid that https://gustavo-fine-guitars.myshopify.com/discount/GR13JsCWCTgQrOgiuV-TRXB_/?redirect=/cart/add?items%5B%5D%5Bid%5D=39879309459534%26items%5B%5D%5Bquantity%5D=1%26items%5B%5D%5Bselling_plan%5D=574554190%26return_to=/checkout was the only format I could find that supports adding what I need.

 

The way you suggested, unfortunately, the discount doesn't get applied, and I'm also unable to add the Selling Plan ID, which is necessary for the product to be added as a subscription.


Omar
Partner - Platinum
Forum|alt.badge.img+46
  • 2025 Champion
  • 494 replies
  • July 29, 2023

Should work according to Shopify documentation: https://help.shopify.com/en/manual/products/details/cart-permalink#customizing-a-cart-permalink

 

Omar Lovert // Polaris Growth // Klaviyo Master Platinum Partner

We help with e-commerce growth through CRO, Klaviyo and CVO