Campaigm UTM URL paramaters being removed from product pages

ttps://www.example.com/products/product1?utm_source=facebook&utm_medium=paid_social&utm_campaign=modelvideo&utm_content=modelvideo&fbclid=xxxxxxxxxxxxxxxx

but automatically redirects to the variant URL > https://www.example.com/products/product1?variant=123456789

any solution to avoid this redirection? we want to track each campaign’s activities and conversion.

Hi @Zyber_Limited ,

Based on the example you sent:

https://www.example.com/products/product1?variant=123456789

This example page has already the question mark …./product1?variant…/

So using one more question mark won’t be working.

So I suggest using ampersand (&) instead, you might also need to include equal sign before the ampersand.

I recommend using this tool: https://ga-dev-tools.web.app/campaign-url-builder/

It will generate the url with the UTM parameter for you — you will see if you need to use the ampersand and the equal sign. Try this out.

Maybe this could help.

Just use this URL and it’ll be fine:

https://www.example.com/products/product1?variant=123456789**&**utm_source=facebook&utm_medium=paid_social&utm_campaign=modelvideo&utm_content=modelvideo&fbclid=xxxxxxxxxxxxxxxx

Notice the & after the variant ID in the URL (bolded to show you).

1 Like

Hi @Josh_Uebergang ,

Happy to hear that’s working. So, no equal sign was needed, just an ampersand. Great!

I’m struggling with this issue too and the suggested solutions do not work. Take this URL:

https://shop.heddels.com/collections/battenwear/products/bouldering-pants-caramel-fw20?variant=39575475978307

If I add a utm_medium=email like so:

https://shop.heddels.com/collections/battenwear/products/bouldering-pants-caramel-fw20?variant=39575475978307&utm_medium=email

The utm_medium parameter is stripped (I believe by JS) and I end up at the original URL:

https://shop.heddels.com/collections/battenwear/products/bouldering-pants-caramel-fw20?variant=39575475978307

This happens with any added query param other than variant.

Does anyone know how I can resolve this?

2 Likes

Hi @KutokuTim ,

it’s weird that it isn’t working. It can be also because of some redirects:

https://shop.heddels.com/collections/battenwear/products/bouldering-pants-caramel-fw20?variant=39575475978307

https://shop.heddels.com/products/bouldering-pants-caramel-fw20?variant=39575475978307

Which of these is redirect? Plus, what’s your primary domain? Isn’t there redirect?

And have you tried using hashtag (#) instead of the first ($)?

Hey @Niki_K , thanks for responding!

Any URL that uses a variant query parameter will have all other query parameters stripped. This is not happening due to a redirect as I can see in Chrome’s web inspector that the page’s status is a 200. Here’s a screengrab — https://share.getcloudapp.com/JruxdoZO

The site’s Shopify domain is https://heddels.myshopify.com and this exhibits the same behaviour.

> And have you tried using hashtag (#) instead of the first ($)?

Can you clarify that? There are no $ signs in the URL.

Thanks!

Hi @KutokuTim ,

I’ve just checked the page’s status and I can see 200 as well. So, yeah this won’t be the problem.

To the third point – I’m sorry, I wrote a wrong sign :grinning_face_with_smiling_eyes: I meant using anchor character (#) instead of ampersand (&) before the utm_source → …#utm_source=…

Maybe the problem might be also in the analytics you’re using? Are you using analytics.js or ga.js? Because by default, analytics.js will search for UTM parameters in both the query string and anchor of the current page’s URL, but ga.js won’t. If I’m not mistaken, you have to allow it in the analytics, see the screenshot and here is also the link.

Thanks again, @Niki_K

> Maybe the problem might be also in the analytics you’re using? Are you using analytics.js or ga.js? Because by default, analytics.js will search for UTM parameters in both the query string and anchor of the current page’s URL, but ga.js won’t. If I’m not mistaken, you have to allow it in the analytics, see the screenshot and here is also the link.

Create info! I did not know this. However, unfortunately the param rewriting issue happens with any and all params (other than the variant param).

For example, this URL uses foo=bar and that will be removed too.

https://shop.heddels.com/products/bouldering-pants-caramel-fw20?variant=39575475978307&foo=bar

It’s strange that this rewriting only occurs when directly linking to a product that has variants. All other Shopify URLs seem to work fine. Do you think it’s a theme issue?

EDIT

I also noticed this happens to other sites, for example — https://www.rogueterritory.com/collections/skinny-leg/products/sk-copper-selvedge-canvas?variant=33078317416553&foo=bar — so it doesn’t seem specific to our site.

Thanks!

2 Likes

Hi @KutokuTim ,

thanks for update and finding out out that this is happening only for product variants and also, for other pages.

  • Sure, the problem might be connected to theme. What could also work is this. If you have a product with a variant, you can see that the variant URL changes. If you choose size M, the variant URL xxxxxxx.com/collections/xxxxx?=123456789 is different to when choosing size L. So, the solution could be to remove the variants URL from the code. Then, I think you could use the UTMs parametr without problem because you would have only one default page. However, it has also a downsize – you won’t be able to share the URL with the specific variant and not sure if this wouldn’t mess up adding the products to cart. I found a thread in Shopify community, which discuss the variant URL. Maybe you could check it out? https://community.shopify.com/c/shopify-design/removing-product-variant-url-v/td-p/357768/page/2
  • The utm parameters are stripped because the page url includes the question mark and the equal sign and we don’t know what other sign to use. :grinning_face_with_smiling_eyes:

Hey @Niki_K

Just to follow up on this. I believe I have resolved the issue. I have some code that requires a query param to exist in order to execute (and I thought this was not running because of the query param removal) but it turns out that this code executes before Shopify’s Javascript that re-writes the query params. So for us at least this is not an issue.

Really appreciate the assistance though. Thanks again!

Hi @KutokuTim ,

okay! Great! Thanks for the update!

Hi @KutokuTim

We are having the same issue and unfortunately Shopify Support says that it is not their scope of work. Could you please detail how you solved the issue?

Many thanks in advance

Hi @LuisGomesHM

Well, we were lucky that the problem actually didn’t affect us. We have a code snippet installed in the Shopify site’s HTML. This code snippet requests a JS file and sends the query parameters along with that request. This request happens before Shopify’s code removes the query parameters so we were a bit lucky.

I do believe this is a Shopify issue and from their response to you it sounds like either don’t want to fix it, or don’t understand the problem.

Sorry I couldn’t be more help.

Hi everyone,

Did this ever get resolved. I tried all the combinations suggested here but nothing worked. In all cases, the URLs would change to the base shopify url with the variant code at the end.

I tried:
removing the variant part of the url
Add & after variant and before the start of UTMs
Add # after variant and before the start of UTMs

1 Like

can you provide the code?

I am facing same issue

here is an example https://www.farpavilions.com/products/two-tone-white-washed-hand-carved-transitionall-arched-bookcase?variant=39837150740561#utm_source=pinterest&utm_medium=cpc&utm_campaign=office_furniture

please correct the URL with UTMs so I can use in paid campaigns

@KutokuTim Would it be possible for you to share the code snippet that you are using to avoid the issue? Thank you in advance!

Facing exactly the same issue and none # ? or & are working. Is it because of some shopify app or a theme issue?

Hey there,

We have the same problem adding a URL parameter for affiliation purposes. In some cases, generally, a product variant, the affiliation param, and the UTM params would just be wiped … This won’t give the script the time to register this parameters …

This sounds crazy that Shopify (or the app causing this problem) did not think about adding all the other parameters back after the Javascript URL cleanup.

If I take the example on this website :

https://www.farpavilions.com/products/two-tone-white-washed-hand-carved-transitionall-arched-bookcase?variant=39837150740561&test=test

The part “&test=test” is wiped of the URL!

Why is this happening? for what purpose? As the variant remains the same.

It’s hard to think about using another character like “#” to fix the issue, as the whole system is based on query string (URL get params).

Anybody knows if this Javascript redirection is made by Shopify or an app ?

Thanks in advance