cedaro / woocommerce-coupon-links

A WordPress plugin to automatically apply WooCommerce coupon codes to the cart via a URL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not apply when used together with UTM tags

GAPP99 opened this issue · comments

Hey guys.

It does not seem to work if you add UTM tags to the url as well. Below is an example:
https://website.com/?coupon_code=COUPON&utm_source=google&utm_medium=pcp&utm_campaign=spring

Is there a way for me to use UTM tags too?

I did a quick test locally and it looks like the coupon was applied correctly. Can you let us know what exactly isn't working? Does it work when you remove the UTM tags?

It seems not to wait for the coupon to qualify. At least it is working if I remove the utm tag.

Try on our site and see if it applies on checkout in incognito: https://x/?coupon_code=x&utm_source=google&utm_medium=pcp&utm_campaign=spring

I'm not sure what kind of restrictions you have on the coupon, but if you add a product to the cart at the same time, it looks like it's working.

https://example.com/checkout/?add-to-cart=52&quantity=1&coupon_code=x&utm_source=google&utm_medium=pcp&utm_campaign=spring

But that’s not the intention. We want to let the coupon wait till the cart is active. Try removing the utm, then it will work as intended.

Ok, so I do see that it works when the cart is empty and the UTM parameter is missing. I've tried a bunch of different things and here's what works and doesn't work for me:

Non-empty Cart

If the cart is not empty or a product is added at the same time, the coupon code is applied correctly.

Empty Cart

These URLs appear to work correctly and a wp_woocommerce_session_xxxx cookie is set when loading them.

These URLs don't work and the wp_woocommerce_session_xxxx cookie is missing.


I tested all these variations locally and they all work. There's not anything in this plugin that handles UTM parameters and I'm not aware of anything in WooCommerce core that would cause a problem, either.

My best guess at this point is it's a caching issue or conflict with another plugin. I see you're using Cloudflare and WP Rocket, so you might start there. It also looks like your host is responding with a cache hit header, so you might reach out to them as well to see if they have special rules for UTM parameters.

Hmmm, I see your point. I'll try to get in touch with them and figure out if there's something I can do. Would you mind editing the URL and code to "x", to stay anonymous?

No problem on the the edit. I made that change yesterday. Good luck getting the issue resolved and let us know what you find out!