Solved

Klaviyo breaking URL with multiple parameters


Badge

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?

 

icon

Best answer by Taylor Tarpley 25 July 2023, 03:13

View original

10 replies

Badge

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. 

Badge

@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.

Userlevel 7
Badge +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

Badge

@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?

Userlevel 7
Badge +60

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

Badge

@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

Userlevel 7
Badge +60

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

Userlevel 7
Badge +44

@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

Badge

@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.

Userlevel 7
Badge +44

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

Reply